From: Michael J. Rubinsky Date: Sat, 1 Jan 2011 21:32:00 +0000 (-0500) Subject: use SquareThumb by default for the mobile thumbnails X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=a1e1c9d3cfe59c88d6bf16ea215263d65503fb6a;p=horde.git use SquareThumb by default for the mobile thumbnails allow styles to specify width and height in certain cases as well --- diff --git a/ansel/config/styles.php.dist b/ansel/config/styles.php.dist index cca404b5d..dd8030cc1 100644 --- a/ansel/config/styles.php.dist +++ b/ansel/config/styles.php.dist @@ -156,3 +156,15 @@ $styles['ansel_lightbox_simple_polaroid'] = array( 'background' => 'none', 'gallery_view' => 'GalleryLightbox' ); + +/* Style for specifying mobile specific views. Ansel looks for this + * style when rendering on a mobile device. + */ +$styles['ansel_mobile'] = array( + 'name' => 'ansel_mobile', + 'title' => _("Mobile View"), + 'thumbstyle' => 'SquareThumb', + 'background' => 'none', + 'width' => 75, + 'height' => 75, +); \ No newline at end of file diff --git a/ansel/lib/Gallery.php b/ansel/lib/Gallery.php index 622758c4d..872696d54 100644 --- a/ansel/lib/Gallery.php +++ b/ansel/lib/Gallery.php @@ -1012,7 +1012,7 @@ class Ansel_Gallery extends Horde_Share_Object_Sql_Hierarchical implements Seria foreach ($images as $img) { $i = new StdClass(); $i->id = $img; - $i->url = Ansel::getImageUrl($img, 'mini', false, Ansel::getStyleDefinition('ansel_mobile'))->toString(); + $i->url = Ansel::getImageUrl($img, 'thumb', false, Ansel::getStyleDefinition('ansel_mobile'))->toString(); $json->imgs[] = $i; } } diff --git a/ansel/lib/ImageGenerator/SquareThumb.php b/ansel/lib/ImageGenerator/SquareThumb.php index 2cc948c51..e709091f7 100644 --- a/ansel/lib/ImageGenerator/SquareThumb.php +++ b/ansel/lib/ImageGenerator/SquareThumb.php @@ -16,6 +16,12 @@ class Ansel_ImageGenerator_SquareThumb extends Ansel_ImageGenerator { parent::__construct($params); $this->title = _("Square Thumbnails"); + if (empty($this->_params['width'])) { + $this->_params['width'] = $this->_style->width; + } + if (empty($this->_params['height'])) { + $this->_params['height'] = $this->_style->height; + } } /** diff --git a/ansel/lib/Style.php b/ansel/lib/Style.php index 1b12fad42..d3903a281 100644 --- a/ansel/lib/Style.php +++ b/ansel/lib/Style.php @@ -26,6 +26,8 @@ class Ansel_Style * to display on the gallery view. * e.g. Array('Geotag' => array(), * 'Tags' => array('view' => 'gallery')) + * 'width' - Optional width of generated thumbnails. + * 'height' - Option height of generated thumbnails. * 'image_widgets' - @TODO: not yet implemented. * * @@ -58,7 +60,7 @@ class Ansel_Style public function getHash($view) { if ($view != 'screen' && $view != 'mini' && $view != 'full') { - $view = md5($this->thumbstyle . '.' . $this->background); + $view = md5($this->thumbstyle . '.' . $this->background . (!empty($this->width) ? $this->width : '') . (!empty($this->height) ? $this->height : '')); } return $view; @@ -76,7 +78,7 @@ class Ansel_Style return $class; } - return $this->_properties[$property]; + return !empty($this->_properties[$property]) ? $this->_properties[$property] : null; } public function __isset($property)