Hi,

My problem is that my client insists in uploading big pictures, for thumbnail display is no problem, i set a preset in imagecache and its done, but when someone whant to see the picture bigger and click on the thumbnail it try to open the original (default behavior), but they are too big and never are show.

So, there is any way to, when the user click on the thickbox thumbnail image, instead off open the original .jpg it point to/ open a imagecache image?

regards

Comments

frjo’s picture

Thickbox will open any image URL that you point it to. So what you need to to is change the address in the link.

Another way to deal with the problem that users refuse to scale down there images is to let Drupal do it for them.

Go to "admin/settings/uploads" and set the "Maximum resolution for uploaded images". If users upload images bigger then this Drupal with scale them down automatically.

If you are using the image module it may have its own settings for this.

diegohermes’s picture

Thanks for the answer, i will try alter the upload configs, this should fix the problem.

regards

mathieu’s picture

I just did that, works like a charm. Needed to create the following function in template.php, in my theme directory (you will need to replace "YOURTHEMENAME" and "YOURPRESETNAME") :

/**
 * Implementation of theme_imagefield_image_imagecache_thickbox().
 */
function YOURTHEMENAME_imagefield_image_imagecache_thickbox($namespace, $field, $path, $alt = '', $title = '', $attributes = NULL) {
  $attributes = drupal_attributes($attributes);
  $imagecache_path = file_create_url(file_directory_path() .'/imagecache/'. $namespace .'/'. $path);
  $image = '<img src="'. $imagecache_path .'" alt="'. check_plain($alt) .'" '. $attributes .' />';

  return l($image, file_create_url(file_directory_path() .'/imagecache/YOURPRESETNAME/'. $path), array('title' => $title, 'class' => 'thickbox', 'rel' => $field['type_name']), NULL, NULL, FALSE, TRUE);
}

Maybe add this snippet to the documentation?

Mathieu

lias’s picture

Thanks for the snippet

jjjames’s picture

I can't get either of these methods to work. The jpg dimensions were larger than I specified as MAX and it didn't get resized. Could this be because I was logged in as user1? Also, the code snippet didn't work for me.
Any suggestions?

thanks

jomtois’s picture

From this post : http://drupal.org/node/128080

This worked for me. You need to have the CCK module loaded.

  • CCK (the module is called 'Content', not CCK)
  • Imagefield ("Image" under CCK in "Modules" admin

You can create an imagefield for any content you define that will contain an option to specify maximum resolution. When you upload the picture into that field, it will be scaled on the server. Then Thickbox will point to that version automatically. Read the post by konsumer in the above link, it is probably clearer than I am describing, although having to do with galleries (good tutorial for that).

frjo’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.