mirror of
https://github.com/silverstripe/silverstripe-cms
synced 2024-10-22 08:05:56 +02:00
ENHANCEMENT: made default image width & height box configurable through setter method
This commit is contained in:
parent
9e5af18b5c
commit
a2b77cebcb
@ -10,6 +10,19 @@ class ThumbnailStripField extends FormField {
|
||||
protected $parentField;
|
||||
protected $updateMethod;
|
||||
|
||||
/**
|
||||
* Make default image width & height configurable
|
||||
* @param int $size
|
||||
*/
|
||||
protected static $default_image_width = 600;
|
||||
public static function set_default_image_width($size = 600) {
|
||||
self::$default_image_width = $size;
|
||||
}
|
||||
protected static $default_image_height = 600;
|
||||
public static function set_default_image_height($size = 600) {
|
||||
self::$default_image_height = $size;
|
||||
}
|
||||
|
||||
/**
|
||||
* If this is enabled, then ommitting a folderID when calling getimages will search ALL folders.
|
||||
* This is the legacy behaviour.
|
||||
@ -103,17 +116,17 @@ class ThumbnailStripField extends FormField {
|
||||
$thumbnail = $image->getFormattedImage('StripThumbnail');
|
||||
|
||||
if ($thumbnail instanceof Image_Cached) { //Hack here...
|
||||
// Constrain the output image to a 600x600 square. This is passed to the destwidth/destheight in the class, which are then used to
|
||||
// Constrain the output image to a widthxheight square. This is passed to the destwidth/destheight in the class, which are then used to
|
||||
// set width & height properties on the <img> tag inserted into the CMS. Resampling is done after save
|
||||
$width = $image->Width;
|
||||
$height = $image->Height;
|
||||
if($width > 600) {
|
||||
$height *= (600 / $width);
|
||||
$width = 600;
|
||||
if($width > self::$default_image_width) {
|
||||
$height *= (self::$default_image_width / $width);
|
||||
$width = self::$default_image_width;
|
||||
}
|
||||
if($height > 600) {
|
||||
$width *= (600 / $height);
|
||||
$height = 600;
|
||||
if($height > self::$default_image_height) {
|
||||
$width *= (self::$default_image_height / $height);
|
||||
$height = self::$default_image_height;
|
||||
}
|
||||
|
||||
$result .=
|
||||
|
Loading…
Reference in New Issue
Block a user