Hi all, I'm new to drupal, but have been programming php for years.

Using drupal 6.8

I wanted to have the thickbox modal window display images that have been generated by imagecache.
I couldn't find a way to do this, as the href always gets set directly to the original file, regardless of the paramaters in my gallery view (setting Thickbox: squarethumbnail image)

Sure, Thickbox "resizes" it to have it display in the browsers window, but there's actually no resizing going on other than the browsers rendering which is pretty ugly. Besides, as an experiment I wanted to have the Thickbox window the same size for the whole gallery, even if this meant upsizing some images.

So in thickbox.module:theme_imagefield_image_imagecache_thickbox(), I changed line 196

from

return l($image, file_create_url($path), array('html' => TRUE, 'attributes' => array('title' => $title, 'class' => 'thickbox', 'rel' => 'gallery-'. $gid)));

to

return l($image, imagecache_create_url("thickbox_display",$path), array('html' => TRUE, 'attributes' => array('title' => $title, 'class' => 'thickbox', 'rel' => 'gallery-'. $gid)));

and I created an ImageCache Preset called thickbox_display. Now I can setup that preset to size/grayscale/crop/rotate/etc the images that display in the ThickBox popup.

My Support Questions are:
1) How should I do this? I know I shouldn't hack on the thickbox.module directly. Where should I redefine theme_imagefield_image_imagecache_thickbox() ?

2) Where can I find documentation or details about how to go about making this configurable? i.e. - Being able to tell thickbox via the admin interface which preset to use to display in the thickbox popup. ?

Many thanks, de facto for all the work so far, and also anticipated for helping out on this one, from somebody who's only just discovering the mega timesaving power of drupal!!

k.

Comments

frjo’s picture

Category: support » feature

Check out the 6-dev version, I added this feature to it some weeks ago.

The setting is named "Image cache preset". As of now it's a global setting affecting all thickboxes. I think I will make it a per image field instans setting in the future.

So for this you don't need to change the theme function but for next time this is how you do it the proper Drupal way.

All functions that start with "theme_" are possible to override in your themes template.php file. Just copy the theme_imagefield_image_imagecache_thickbox() function to your template.php file and rename it to:

[your_theme_name]_imagefield_image_imagecache_thickbox()

And then you can make changes like the one you mention above.

More info: Using Theme Override Functions