1
0
mirror of https://github.com/processwire/processwire.git synced 2025-08-16 19:54:24 +02:00

Add support for $config->imageSizes setting which lets you name and predefine image sizes/options that you can later refer to by name on any $image->size() call (via the width argument).

This commit is contained in:
Ryan Cramer
2020-02-21 11:23:02 -05:00
parent ed05a4a356
commit 695dd79db6
3 changed files with 97 additions and 7 deletions

View File

@@ -616,6 +616,40 @@ $config->fileContentTypes = array(
'mp3' => 'audio/mpeg',
);
/**
* Named predefined image sizes and options
*
* Specify associative arrays of predefined image sizes indexed by name.
* Each item should have at least 'width' and 'height' indexes. But they can also have any
* other option accepted by the `Pageimage::size()` method `$options` argument.
*
* You can use your defined sizes by name in a Pageimage::size() call by specifying the
* size name rather than the `$width` argument, like this:
* ~~~~~~
* $image = $page->images->first();
* $landscape = $image->size('landscape');
* echo "<img src='$landscape->url' alt='$landscape->description' />";
* ~~~~~~
* Feel free to completely overwrite the default $config->imageSizes in your /site/config.php
* file * as this particular setting is not used by the core.
*
* @var array
* @since 3.0.151
*
*/
$config->imageSizes = array(
// Example 1: Landscape (try this one if you want to test the feature)
'landscape' => array('width' => 600, 'height' => 300),
// Example 2: Thumbnails in admin (260 height, proportional width)
// 'admin' => array('width' => 0, 'height' => 260),
// Example 3: Portrait, with additional options:
// 'portrait' => array('width' => 300, 'height' => 500, 'quality' => 80, 'suffix' => 'portrait'),
// Example 4: Square size cropping towards (preserving) top/center (north):
// 'squareNorth' => array('width' => 400, 'height' => 400, 'cropping' => 'north'),
);
/**
* Image sizer options
@@ -1318,7 +1352,16 @@ $config->adminEmail = '';
* @var string
*
*/
$config->fatalErrorHTML = "<p style='background:crimson;color:white;padding:0.5em;font-family:sans-serif;'><b>{message}</b><br /><br /><small>{why}</small></p>";
$config->fatalErrorHTML = "<p style='background:crimson;color:white;padding:1em;font-family:sans-serif;font-size:16px;line-height:20px;clear:both'>{message}<br /><br /><small>{why}</small></p>";
/**
* HTTP code to send for fatal error (typically 500 or 503)
*
* @var int
* @since 3.0.151
*
*/
$config->fatalErrorCode = 500;
/**
* Settings for modal windows