Fix generation of mobile thumbnails when not using vfs-direct.
authorMichael J. Rubinsky <mrubinsk@horde.org>
Tue, 4 Jan 2011 01:11:52 +0000 (20:11 -0500)
committerMichael J. Rubinsky <mrubinsk@horde.org>
Tue, 4 Jan 2011 01:13:20 +0000 (20:13 -0500)
Also, add a config switch for tinySrc.mobi support. Mostly to ease
testing while using locahost ;)

ansel/config/conf.xml
ansel/img/thumb.php
ansel/lib/Ansel.php
ansel/lib/Gallery.php
ansel/templates/mobile/javascript_defs.php

index 985fc25..1b78488 100644 (file)
    if available when generating mini or square thumbnails? This gives a better
    change that the crop will contain an interesting part of the image, but will
    increase CPU usage during image generation."></configboolean>
+   <configboolean name="tiny" desc="Should Ansel use the TinySrc.mobi webservice
+   to generate mobile image screen views if appropriate? The gallery must either
+   be publicly viewable or you must be using the VFS direct option above. If
+   this is enabled, and these conditions are not met, Ansel will fall back to
+   an average sized mobile image. Note also that if you are using localhost or
+   something similar as the server name, this will fail.">false</configboolean>
    <configstring name="num_uploads" desc="How many photos should a user be
    allowed to upload at once?">5</configstring>
    <configstring name="font" required="false" desc="What font would you like
index 2b81c8d..bd7dbab 100644 (file)
@@ -13,11 +13,15 @@ Horde_Registry::appInit('ansel');
 
 $thumbstyle = Horde_Util::getFormData('t');
 $background = Horde_Util::getFormData('b');
+$w = Horde_Util::getFormData('w');
+$h = Horde_Util::getFormData('h');
 
 // Create a dummy style object with only what is needed to generate
-if ($thumbstyle && $background) {
+if ($thumbstyle || $background || $w || $h) {
     $style = new Ansel_Style(array('thumbstyle' => $thumbstyle,
-                                   'background' => $background));
+                                   'background' => $background,
+                                   'width' => $w,
+                                   'height' => $h));
 } else {
     $style = null;
 }
index 223f363..89a5d6e 100644 (file)
@@ -398,6 +398,12 @@ class Ansel
             if (!is_null($style)) {
                 $params['t'] = $style->thumbstyle;
                 $params['b'] = $style->background;
+                if ($style->width) {
+                    $params['w'] = $style->width;
+                }
+                if ($style->height) {
+                    $params['h'] = $style->height;
+                }
             }
 
             return Horde::url('img/' . $view . '.php', $full)->add($params);
index 83ff03c..58abab5 100644 (file)
@@ -1032,7 +1032,8 @@ class Ansel_Gallery extends Horde_Share_Object_Sql_Hierarchical implements Seria
         }
 
         if ($full) {
-            $json->tiny = ($GLOBALS['conf']['vfs']['src'] == 'direct' || $this->hasPermission('', Horde_Perms::READ));
+            $json->tiny = ($GLOBALS['conf']['image']['tiny'] &&
+                           ($GLOBALS['conf']['vfs']['src'] == 'direct' || $this->hasPermission('', Horde_Perms::READ)));
             $json->sg = array();
             if ($this->hasSubGalleries()) {
                 $sgs = $GLOBALS['injector']->getInstance('Ansel_Storage')->listGalleries(array('parent' => $this->getId(), 'all_levels' => false));
@@ -1045,8 +1046,8 @@ class Ansel_Gallery extends Horde_Share_Object_Sql_Hierarchical implements Seria
             foreach ($images as $img) {
                 $i = new StdClass();
                 $i->id = $img->id;
-                $i->url = Ansel::getImageUrl($img->id, 'thumb', false, Ansel::getStyleDefinition('ansel_mobile'))->toString();
-                $i->screen = Ansel::getImageUrl($img->id, 'screen', $json->tiny, Ansel::getStyleDefinition('ansel_default'))->toString();
+                $i->url = Ansel::getImageUrl($img->id, 'thumb', false, Ansel::getStyleDefinition('ansel_mobile'))->toString(true);
+                $i->screen = Ansel::getImageUrl($img->id, 'screen', $json->tiny, Ansel::getStyleDefinition('ansel_default'))->toString(true);
                 $i->fn = $img->filename;
                 $json->imgs[] = $i;
             }
index 6aba72a..e4fbf8a 100644 (file)
@@ -3,7 +3,6 @@ global $prefs, $registry;
 
 $ansel_webroot = $registry->get('webroot');
 $horde_webroot = $registry->get('webroot', 'horde');
-$has_tasks = $registry->hasInterface('tasks');
 
 /* Variables used in core javascript files. */
 $code['conf'] = array(