Thickbox integration
rapsli - February 28, 2008 - 07:37
| Project: | Inline |
| Version: | 6.x-2.x-dev |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | needs review |
Description
really enjoy your module. It would though be nice if Thickbox could be integrated. Right now when I activate the link settings I'm just being directed to the image thus leaving the page. Using thickbox to display the full image would just look soooo much nicer.
Keep it up.

#1
Thickbox integration is quite simple... here is a patch against 5.x-1.1.
All I did was add the tags that thickbox wants on the images. I'm happy to add auto detection or a setting to turn it on and off or whatever...
What do you think? http://five.marmot.com/node/3
#2
Way cool!
#3
Hey, even better, is that if you don't want to mess with the module at all, you can simply override the theme... just add this to your template.php file:
<?php
function phptemplate_inline_img($file, $field) {
$title = (!empty($file->title) ? $file->title : $file->filename);
$inline_preset = $field == 'teaser' ? 'inline_teaser_preset' : 'inline_full_preset';
if (module_exists('imagecache') && variable_get($inline_preset, '') != '') {
$image = theme('imagecache',
variable_get($inline_preset, ''),
$file->filepath,
$title,
$title,
array('class' => 'inline')
);
}
else {
$image = theme('image',
$file->filepath,
$title,
$title,
array('class' => 'inline')
);
}
if (variable_get('inline_link_img', '1')) {
$attributes = array(
'class' => 'inline-image-link thickbox',
'rel' => 'gallery-' . $file->nid,
'title' => t("View") .': '. $title,
);
$html = l($image, $file->filepath, $attributes, NULL, NULL, FALSE, TRUE);
}
else {
$html = $image;
}
return $html;
}
?>
It's just the patched function copied into the theme with the function name changed.
More info: http://drupal.org/node/55126
?>
Happy theming!
#4
@JamieR: Could you post the (missing) patch from #1 again, please?
#5
Sure... sorry I forgot the patch the first time.
I made one for the 5.x-1.1 version and one against HEAD.
Thanks, Jamie.
#6
Hmmm... having problems with the attachment. Maybe that's why it didn't appear on the original post...
#7
Patch #6 worked for me in a couple of different environments:
Patch applied to latest (2008-Jun-15) 5.x-1.x-dev.
#8
Well, I'm putting this on-hold for just one reason: I've implemented multiple add-on scripts in jQuery Lightbox that add the necessary attributes to Inline, Image Assist, Image, and Image Gallery images to load them in a jQuery Lightbox.
My key question is whether Inline really should implement support for a never-ending list of JavaScript behaviors, or whether all of this should happen the other way around: A JavaScript behavior (like Thickbox) that wants to support Inline (and other contents) needs to implement support for that content on its own.
#9
True.
But it might be nice to put a note in the instruction with an example of how to use the theme override functions to add support of other javascript libraries?
Just a thought.
I wish I had known that jQuery Lightbox was already integrated... so many modules... I would love to see for each module a list of other modules that have been designed to work together... that would be nice. :)
Keep up the great work.
Jamie.
#10
Well, a theme override function would be a culprit for regular users.
What if we would add a
<?php$attributes = array_merge($attributes, module_invoke_all('inline_attributes' [, $context] ));
?>
right after the definition of $attributes? That would allow any module to alter the attributes of the embedded image.
I thought of $context being a $node object, but that's not (yet) available in this case.
#11
I love it.
I'm not familiar enough with the project to understand how you would use the $context var, but it would be great to have that functionality available for integration.
#12
Simpler than patching the module it's better to patch inline.theme.inc. Search for 'class' => 'inline-image-link and then add thickbox in front of it. So it'll look like this 'class' => 'inline-image-link thickbox'. That way all inline images will be part of two classes inline-image-link and thickbox. I did this way and everything went ok.
#13
The patch attached, this is for version 6.x-1.0