#318430 by dman and drewish: Show a 'preview' image when editing imagecache presets...
authorandrew morton
Wed, 18 Mar 2009 09:34:21 +0000 (09:34 +0000)
committerandrew morton
Wed, 18 Mar 2009 09:34:21 +0000 (09:34 +0000)
imagecache_ui.module
sample.png [new file with mode: 0644]

index 7fdf57d..d13b214 100644 (file)
@@ -352,6 +352,25 @@ function imagecache_ui_preset_form($presetid) {
     '#type' => 'submit',
     '#value' => t('Update Preset'),
   );
+
+  // Display a preview image for this action. Put it below the submit button so
+  // users don't have to do a bunch of scrolling.
+  $preview_path = file_create_path('imagecache_sample.png');
+  if (!file_exists($preview_path)) {
+    // Copy of the image into the files directory so rather than generating it
+    // from the original so we don't end up creating subdirectories mirroring
+    // the path to the this module.
+    $preview_path = drupal_get_path('module', 'imagecache_ui') .'/sample.png';
+    file_copy($preview_path, 'imagecache_sample.png');
+  }
+  imagecache_image_flush($preview_path);
+  $imagecache_path = imagecache_create_url($preset['presetname'], $preview_path) .'?'. time();
+  $form['preview'] = array(
+    '#type' => 'item',
+    '#title' => t('Preview'),
+    '#value' => l($imagecache_path, $imagecache_path) .'<br />'. l("<img src='$imagecache_path' />", $imagecache_path, array(), NULL, NULL, FALSE, TRUE),
+  );
+
   return $form;
 }
 
diff --git a/sample.png b/sample.png
new file mode 100644 (file)
index 0000000..f8ced55
Binary files /dev/null and b/sample.png differ