ENHANCEMENT: made default image width & height box configurable through setter method

This commit is contained in:
micschk 2011-11-24 07:04:54 +01:00 committed by Will Rossiter
parent 9e5af18b5c
commit a2b77cebcb
1 changed files with 20 additions and 7 deletions

View File

@ -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 .=