]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
added ability to create thumbnails for images that previously failed
authorCash Costello <cash.costello@gmail.com>
Wed, 9 Sep 2009 00:58:37 +0000 (00:58 +0000)
committerCash Costello <cash.costello@gmail.com>
Wed, 9 Sep 2009 00:58:37 +0000 (00:58 +0000)
actions/create_thumbnails.php [new file with mode: 0644]
actions/imtest.php
actions/upload.php
contributions.txt
languages/en.php
views/default/tidypics/admin/imagelib.php
views/default/tidypics/admin/thumbnails.php [new file with mode: 0644]
views/default/tidypics/admin/tidypics.php

diff --git a/actions/create_thumbnails.php b/actions/create_thumbnails.php
new file mode 100644 (file)
index 0000000..3fefb4f
--- /dev/null
@@ -0,0 +1,61 @@
+<?php\r
+       /**\r
+        * Tidypics Thumbnail Creation Test\r
+        *\r
+        *  Called through ajax\r
+        */\r
+        \r
+       include_once dirname(dirname(dirname(dirname(__FILE__)))) . "/engine/start.php";\r
+       include dirname(dirname(__FILE__)) . "/lib/resize.php";\r
+       \r
+       global $CONFIG;\r
+       \r
+       $guid = $_GET['guid'];\r
+\r
+       $image = get_entity($guid);\r
+       if (!$image || !($image instanceof TidypicsImage)) {\r
+               echo "Unable to get original image";\r
+               return; \r
+       }\r
+       \r
+       $filename = $image->getFilename();\r
+       $container_guid = $image->container_guid;\r
+       if (!$filename || !$container_guid) {\r
+               echo "Error retrieving information about the image";\r
+               return;\r
+       }\r
+       \r
+       $title = $image->title;\r
+       $prefix = "image/" . $container_guid . "/";\r
+       $filestorename = substr($filename, strlen($prefix));\r
+       \r
+       $image_lib = get_plugin_setting('image_lib', 'tidypics');\r
+       if (!$image_lib)\r
+               $image_lib = "GD";\r
+       \r
+       if ($image_lib == 'ImageMagick') { // ImageMagick command line\r
+               \r
+               if (tp_create_imagick_cmdline_thumbnails($image, $prefix, $filestorename) != true) {\r
+                       trigger_error('Tidypics warning: failed to create thumbnails - ImageMagick command line', E_USER_WARNING);\r
+                       echo "Failed to create thumbnails";\r
+               }\r
+               \r
+       } else if ($image_lib == 'ImageMagickPHP') {  // ImageMagick PHP \r
+               \r
+               if (tp_create_imagick_thumbnails($image, $prefix, $filestorename) != true) {\r
+                       trigger_error('Tidypics warning: failed to create thumbnails - ImageMagick PHP', E_USER_WARNING);\r
+                       echo "Failed to create thumbnails";\r
+               }\r
+       \r
+       } else { \r
+               \r
+               if (tp_create_gd_thumbnails($image, $prefix, $filestorename) != true) {\r
+                       trigger_error('Tidypics warning: failed to create thumbnails - GD', E_USER_WARNING);\r
+                       echo "Failed to create thumbnails";\r
+               }\r
+               \r
+       } // end of image library selector\r
+       \r
+       echo "<img id=\"tidypics_image\"  src=\"{$CONFIG->wwwroot}mod/tidypics/thumbnail.php?file_guid={$guid}&amp;size=large\" alt=\"{$title}\" />";\r
+                               \r
+?>\r
index 6ab2b7b8f6762dcce724ab5e37a414b0c8603edf..8d517178548565f9555ab652957fc7c074909e23 100644 (file)
@@ -1,6 +1,6 @@
 <?php\r
        /**\r
-        * Tisypics ImageMagick Location Test\r
+        * Tidypics ImageMagick Location Test\r
         *\r
         *  Called through ajax\r
         */\r
index f330cf7827ffb778d7443a1ae0f03a912c13fddd..209d8e17de6a47430af16cebc2b1900fd196117b 100644 (file)
                        continue;\r
                }\r
                \r
-\r
+               //get and store the exif data\r
+               td_get_exif($file);\r
+               \r
+               \r
+               // resize photos to create thumbnails\r
                if ($image_lib == 'ImageMagick') { // ImageMagick command line\r
                        \r
                        if (tp_create_imagick_cmdline_thumbnails($file, $prefix, $filestorename) != true) {\r
                        $file_for_river = $file;\r
                }\r
 \r
-               //get and store the exif data\r
-               td_get_exif($file);\r
                array_push($uploaded_images, $file->guid);\r
 \r
                // update user/group size for checking quota\r
index 0e947c122e12271457aa58d991a6105408aedaf8..f3427eaca8c55d01dc8d1ec752c12fb03379fa46 100644 (file)
@@ -2,7 +2,7 @@ See individual change logs for contributors to those builds
 \r
 ------------------------------------------------------------------------\r
 Version 1.6.2 Change List\r
-Release Date: \r
+Release Date: 09/03/2009\r
 ------------------------------------------------------------------------\r
 BEGIN VERSION 1.6.2 CHANGES\r
 ------------------------------------------------------------------------\r
index 83e6009367fe800b31670746060baabe36c4add1..f3abfc27e9e39d97e53139c6fd957fd9ff26a991 100644 (file)
@@ -53,6 +53,7 @@
                        'tidypics:settings' => 'Settings',\r
                        'tidypics:admin:instructions' => 'These are the core Tidypics settings. Change them for your setup and then click save.',\r
                        'tidypics:settings:image_lib' => "Image Library",\r
+                       'tidypics:settings:thumbnail' => "Thumbnail Creation",\r
                        'tidypics:settings:download_link' => "Show download link",\r
                        'tidypics:settings:tagging' => "Enable photo tagging",\r
                        'tidypics:settings:photo_ratings' => "Enable photo ratings (requires rate plugin of Miguel Montes or compatible)",\r
@@ -68,7 +69,8 @@
                        'tidypics:settings:largesize' => "Primary image size",\r
                        'tidypics:settings:smallsize' => "Album view image size",\r
                        'tidypics:settings:thumbsize' => "Thumbnail image size",\r
-\r
+                       'tidypics:settings:im_id' => "Image ID",\r
+       \r
                //actions\r
 \r
                        'album:create' => "Create new album",\r
index 8f71c75f21a36781458dc0077c77c909555034c6..deb32d0f3ee5971884cac43958e5ce478fdae5aa 100644 (file)
        if (get_plugin_setting('tagging', 'tidypics') != "disabled")\r
                $num_tags = count_annotations(0, 'object', 'image', 'phototag');\r
 ?>\r
-<p>\r
 <br />\r
+<h3>Overview</h3>\r
+<p>\r
 An image library is required by Tidypics to perform various manipulations: resizing on upload, watermarking, rotation, and cropping.\r
 There are three image library options with Tidypics: PHP extension <a href="http://www.php.net/manual/en/book.image.php">GD</a>, \r
 <a href="http://www.imagemagick.org/">ImageMagick</a> called via a system call, and the PHP extension \r
 <a href="http://pecl.php.net/package/imagick/">imagick</a>. GD is the most common of the three on hosted servers but suffers \r
 from serious memory usage problems when resizing photos. If you have access to ImageMagick (whether through system calls or the\r
 PHP extension), we recommend that you use that.\r
-</p><p>\r
+</p>\r
 <h3>Testing ImageMagick Commandline</h3>\r
+<p>\r
 To use the ImageMagick executables, PHP must be configured to allow calls to exec(). You can check our \r
 <a href="<?php echo $CONFIG->wwwroot . 'mod/tidypics/pages/server_analysis.php'; ?>">server analysis page</a> to find out the \r
 configuration of your server. Next, you need to determine the path to ImageMagick on your server. Your hosting service should \r
 be able to provide this to you. You can test if the location is correct below. If successful, it should display the version of \r
 ImageMagick installed on your server.  \r
 </p>\r
-<p>\r
 <br />\r
+<p>\r
 <?php echo elgg_echo('tidypics:settings:im_path'); ?><br />\r
 <input name="im_location" type="text" />\r
 <input type="submit" value="Submit" onclick="TestImageMagickLocation();" />\r
diff --git a/views/default/tidypics/admin/thumbnails.php b/views/default/tidypics/admin/thumbnails.php
new file mode 100644 (file)
index 0000000..0af5909
--- /dev/null
@@ -0,0 +1,33 @@
+<br />\r
+<h3>Overview</h3>\r
+<p>\r
+This page allows you to create thumbnails for images when the thumbnail creation failed during upload. \r
+You may experience problems with thumbnail creation if your image library in not configured properly or\r
+if there is not enough memory for the GD library to load and resize an image. If your users have \r
+experienced problems with thumbnail creation and you have modified your setup, you can try to redo the\r
+thumbnails. Find the unique identifier of the photo (it is the number near the end of the url when viewing\r
+a photo) and enter it below. \r
+</p>\r
+<h3>Thumbnail Creation</h3>\r
+<p>\r
+<b><?php echo elgg_echo('tidypics:settings:im_id'); ?></b>:\r
+<input name="image_id" type="text" />\r
+<input type="submit" value="Submit" onclick="TestThumbnailCreation();" />\r
+</p>\r
+<div id="im_results"></div>\r
+<script type="text/javascript">\r
+function TestThumbnailCreation()\r
+{\r
+       var image_id = $('input[name=image_id]').val();\r
+       $("#im_results").html("");\r
+       $.ajax({\r
+               type: "GET",\r
+               url: "<?php echo $CONFIG->wwwroot . 'mod/tidypics/actions/create_thumbnails.php'; ?>",\r
+               data: {guid: image_id},\r
+               cache: false,\r
+               success: function(html){\r
+                       $("#im_results").html(html);\r
+               }\r
+       });\r
+}\r
+</script>
\ No newline at end of file
index 3d31bd52e74246154f280169ef4a4a046ab54c23..7aeb3a195983d8be464e95b9f810d76f3f1adbfb 100644 (file)
@@ -7,6 +7,7 @@
        $settingsselect = ''; 
        $statsselect = '';
        $imagelibselect = '';
+       $thumbnailselect = '';
        switch($tab) {
                case 'settings':
                        $settingsselect = 'class="selected"';
@@ -17,6 +18,9 @@
                case 'imagelib':
                        $imagelibselect = 'class="selected"';
                        break;
+               case 'thumbnail':
+                       $thumbnailselect = 'class="selected"';
+                       break;
        }
        
 ?>
@@ -26,6 +30,7 @@
                        <li <?php echo $settingsselect; ?>><a href="<?php echo $CONFIG->wwwroot . 'mod/tidypics/pages/admin.php?tab=settings'; ?>"><?php echo elgg_echo('tidypics:settings'); ?></a></li>
                        <li <?php echo $statsselect; ?>><a href="<?php echo $CONFIG->wwwroot . 'mod/tidypics/pages/admin.php?tab=stats'; ?>"><?php echo elgg_echo('tidypics:stats'); ?></a></li>
                        <li <?php echo $imagelibselect; ?>><a href="<?php echo $CONFIG->wwwroot . 'mod/tidypics/pages/admin.php?tab=imagelib'; ?>"><?php echo elgg_echo('tidypics:settings:image_lib'); ?></a></li>
+                       <li <?php echo $thumbnailselect; ?>><a href="<?php echo $CONFIG->wwwroot . 'mod/tidypics/pages/admin.php?tab=thumbnail'; ?>"><?php echo elgg_echo('tidypics:settings:thumbnail'); ?></a></li>
                </ul>
        </div>
 <?php
@@ -39,6 +44,9 @@
                case 'imagelib':
                        echo elgg_view("tidypics/admin/imagelib");
                        break;
+               case 'thumbnail':
+                       echo elgg_view("tidypics/admin/thumbnails");
+                       break;
        }
 ?>
 </div>