I am sure something like this is in the works and read it can be done with imagecache. I think the benefit of the following would be taking out the need for another module, and a cleaner UI.

Once you create an imagefield inside of a content type, there could be a checkbox for "create thumbnail," and a max height/width scale/resize textbox. Then you could have a variable like $field_image[0]['thumbpath'] to use when theming.

Does this sound useful? Thanks.

Comments

dopry’s picture

Status: Active » Fixed

This is available through imagecache and views. and using the content_format function in your themes.

zach harkey’s picture

Status: Fixed » Active

Reopening this issue because I think the posted solution doesn't address all scenarios.

I completely understand delegating most image manipulation to imagecache and the theme layer. However, I really think imagefield needs to provide a thumbnail, for the administrative form previews. As far as I can tell, the administrative preview thumbnails are actually the full original images scaled down to fit 150px wide. This may work in many cases where only a few small images are being uploaded. In situations where several hi-resolution images (e.g. professional photography at 2400x2400 ) are being uploaded, the whole workflow becomes very unstable if not completely unusable. At the very least, the previews flake out.

A default administrative thumbnail derivitive would really help mitigate this situation, or should I be overriding even the the admin form functions in my theme so the upload previews use imagecache thumbnails?

zach harkey’s picture

Title: Image thumbnails » Thumbnails are needed for administrative form viewing, and should not require imagecache module.
dopry’s picture

You're welcome to submit a patch. I'd be happy to commit it, but It conflicts with some of my current plans of moving this kind of stuff to a lower level, so I won't focus my development time on this feature.

scroogie’s picture

What you could do is build in a check for imagecache, and if existant, use imagecache for scaling down the picture. I think most of the people will use imagefield with imagecache anyway, and lets not build in more self-coded image manipulation operations, we imho already have that spreaded too much in drupal...

zach harkey’s picture

Ok, so I created the following override in my theme's template.php:

function phptemplate_imagefield_image_preview($file, $alt ='', $title='', $attributes = NULL, $getsize= TRUE, $thumbnail = 'thumbnail') {
  $output = '';
  if (module_exist('imagecache') && db_result(db_query("SELECT * FROM {imagecache_preset} WHERE presetname='%s'", $thumbnail)) != '') {
    $image_preview .= theme('imagecache', $thumbnail, $file['filepath']);
  }
  else {
    $image_preview = theme('imagefield_image', $file, $alt, $title, $attributes , $getsize);
  }
  $output .= '<span class="imagefield-image-preview">'. $image_preview .'</span>';
  return $output;
}

And it does what I want on subsequent viewings of the form, but not on the initial upload where I get a broken image icon. If I submit, then view, then edit the form again, the resized imagecache thumbnail displays properly. Am I close here? or am I in left field?

whereisian’s picture

Has this idea been revisited anywhere? I'd love to see this implemented for the same reason. Thanks for the snippet Zach Harkey, I'll be trying that out.

dopry’s picture

The Snippet Zach Harkey has written should work with imagefield 2.x... I just need it as a patch and I need it to check if imagecache is installed when deciding to display the preview...

.darrel.

quicksketch’s picture

Status: Active » Closed (fixed)

We have had thumbnails in theh 3.x version for quite a while now. Let's open a new issue for any enhancements to the current approach.

robomalo’s picture

I am closing the issue. If anyone thinks it should be open, feel free to make it active again. Zach: thanks for the work!