use SquareThumb by default for the mobile thumbnails
authorMichael J. Rubinsky <mrubinsk@horde.org>
Sat, 1 Jan 2011 21:32:00 +0000 (16:32 -0500)
committerMichael J. Rubinsky <mrubinsk@horde.org>
Sat, 1 Jan 2011 21:32:00 +0000 (16:32 -0500)
allow styles to specify width and height in certain cases as well

ansel/config/styles.php.dist
ansel/lib/Gallery.php
ansel/lib/ImageGenerator/SquareThumb.php
ansel/lib/Style.php

index cca404b..dd8030c 100644 (file)
@@ -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
index 622758c..872696d 100644 (file)
@@ -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;
             }
         }
index 2cc948c..e709091 100644 (file)
@@ -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;
+        }
     }
 
     /**
index 1b12fad..d3903a2 100644 (file)
@@ -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.
      * </pre>
      *
@@ -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)