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

JamieR - June 12, 2008 - 23:12

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

rapsli - June 13, 2008 - 04:54

Way cool!

#3

JamieR - June 18, 2008 - 06:02

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

sun - June 19, 2008 - 04:57
Status:active» needs work

@JamieR: Could you post the (missing) patch from #1 again, please?

#5

JamieR - June 19, 2008 - 23:04

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.

AttachmentSize
inline.module_HEAD_thickbox.patch 482 bytes

#6

JamieR - June 19, 2008 - 23:05
Status:needs work» needs review

Hmmm... having problems with the attachment. Maybe that's why it didn't appear on the original post...

AttachmentSize
inline.module_thickbox.patch 477 bytes

#7

micah - July 2, 2008 - 19:42

Patch #6 worked for me in a couple of different environments:

  • Drupal 5.7, ImageCache 5.x-1.6, Thickbox 5.x-1.2
  • Drupal 5.7, ImageAPI 5.x-1.2, ImageCache 5.x-2.1, Thickbox 5.x-2.0

Patch applied to latest (2008-Jun-15) 5.x-1.x-dev.

#8

sun - July 4, 2008 - 23:53

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

JamieR - July 8, 2008 - 18:10

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

sun - July 10, 2008 - 17:49

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

JamieR - July 17, 2008 - 16:41

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

lsrzj - February 2, 2009 - 13:59

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

lsrzj - February 2, 2009 - 14:02

The patch attached, this is for version 6.x-1.0

AttachmentSize
inline.theme_.inc_.patch 503 bytes
 
 

Drupal is a registered trademark of Dries Buytaert.