The thumbnail size is currently hardcoded at 32x32. This patch allows site administrators to configure the thumbnail size.

Comments

David Lesieur’s picture

To be more exact, the thumbnail size was not hardcoded. Only its default value was hardcoded. But no way was provided to override the default. :-) This patch allows admins to override the default.

David Lesieur’s picture

Status: Needs review » Needs work
j0e’s picture

I applied the patch to test. Where is the override form supposed to appear? Admin settings? Don't see any options there for configuring swfupload. And the cck widget doesn't seem to provide settings for configuring the size of the thumbnail. Also: does this patch take care of the way the css is affected. I attempted to simply tweak the hardcoded 32x32 to 100x100 in the admin file for a new default and to modify the .sfwupload-list-mime css to 100width and 100height, but the progress bar which is working by percents gets really squeezed by the new settings.
Joseph

David Lesieur’s picture

The patch adds a new settings page in the Site configuration menu. It also does not affect the CSS, so it's true that there might be a theming issue. I'm not sure how worth the patch is if the admin is required to manually tweak the CSS...

eugenmayer’s picture

Status: Needs work » Needs review

As we have a patch, setting to review

robloach’s picture

What if instead of a given size, it took a given ImageCache preset?

David Lesieur’s picture

Title: Configurable thumbnail size » Generate thumbnails with ImageCache
Status: Needs review » Needs work

It completely invalidates the current patch, but I like this idea. :-)

skilip’s picture

What's the advantage of ImageCache here? We only need a width and a height, don't we?

robloach’s picture

Seems like it, and what happens when ImageCache isn't around? :-)

David Lesieur’s picture

We only need a width and a height until we want a more complex transformation... (e.g. cropping to get square thumbnails)... However, those thumbnails have such a limited use that this kind of requirement can be considered excessive.

Not sure what would happen if ImageCache wasn't around. Could it be acceptable to require it? That may seem exaggerated given its usefulness to SWFUpload, but on the other hand ImageCache-like functionality is in D7 core and therefore has become a standard tool.

A benefit of using ImageCache is that it would become possible to re-use a preset that's also used elsewhere on the site. The same thumbnails could serve multiple purposes, instead of having yet another set of thumbnails that's only useful to SWFUpload.

skilip’s picture

Adding a condition for when imagecache is enabled is easy. I'm a bit afraid of the amount of extra code for this feature. I estimate it will be 40 - 80 lines extra.

eugenmayer’s picture

Skilip we should start to move all this to submodules otherwise this module gets unuseful for a lot of people, as it has to much code + deps. What do you think?

David Lesieur’s picture

Using ImageCache would simplify the thumbnail generation code because all we'd need to do is create the thumbnail's path. The swfupload_thumb() function would mostly disappear. So I think that using ImageCache could actually help SWFUpload focus on its main task.

j0e’s picture

so i went to: admin/settings/swfupload
changed the default from 32x32 to 75x75
no change reflected when i tried the upload.
same 32x32 thumbnail appeared...

steven jones’s picture

Version: 6.x-2.0-beta3 » 6.x-1.x-dev

This patch is against 6.x-1.x

steven jones’s picture

Version: 6.x-1.x-dev » 6.x-2.0-beta3
Assigned: David Lesieur » Unassigned

Attached is a patch for the 2.x branch. It adds support for using an imagecache preset for upload thumbnail generation.

It works, apart from the fact that the thumbnail is displayed as a background-image on a div with a fixed width and height, so although the image is actually bigger/smaller, it doesn't appear to be so.

j0e’s picture

hi Steven, no patch for 6.x-2.0-beta3 attached to your last comment...

steven jones’s picture

StatusFileSize
new7.58 KB

Silly d.o.

This patch needs work, because I've not changed the creation of thumbnails when editing a node, just adding it.

bwoods’s picture

Maybe I'm oversimplifying the error checking for this patch, but I modified the swfupload_admin_settings_validate function slightly:

function swfupload_admin_settings_validate($form, &$form_state) {
  $dimensions = explode('x',$form_state['values']['swfupload_thumb_size']);
  if ((int)($dimensions[0]) < 1 || (int)($dimensions[1]) < 1) {
    form_set_error('swfupload_thumb_size', t('Thumbnail size format must be entered as <strong>WIDTH</strong>x<strong>HEIGHT</strong>.'));
  }
}

This seems to work OK.

patrickroma’s picture

does this also work for beta7?

skilip’s picture

Sorry for the huge delay on this!
I am willing to get this patch in. Cal anyone re-roll this patch against last dev version?

One thing to mention:

The form field 'Thumbnail type' isn't needed if the ImageCache module isn't installed. Please make it conditional.