Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
There was a setting in thickbox to set which image derivative to display in the thickbox. The attached patch creates this same functionality. This is a multiple file patch so apply it from the modules directory.
Changed:
- colorbox.admin.inc - added setting to admin form
- colorbox.module - added "image_derivative" setting to js settings in _colorbox_doheader (hook_init)
- js/colorbox_image_module.js - integrates image_derivative setting into auto linking ... my attempt at making it more general instead of just linking "thumbnail" images
Comments
Comment #1
frjo CreditAttribution: frjo commentedThank you very much for contributing all these Image module integration improvements!
I don't use the Image module myself so I depend on people like you.
How well tested is this?
Comment #2
recrit CreditAttribution: recrit commentedi have had it working on a development site with no issues. ColorBox uses the correct derivative setting when linking the image-attach-body. I believe thickbox linked the gallery thumbnails too, so that's a possible addition to the javascript.
Comment #3
recrit CreditAttribution: recrit commentedhere's a re-roll with added support for image galleries -
ul.images a
, added to js/colorbox_image_module.jsComment #4
frjo CreditAttribution: frjo commentedI have now tested your patch and it seems to work well. I have made some adjustment that I hope you have time to look at and test.
* Some minor naming changes.
* Replace
$("a[rel='image-gallery']", context).colorbox();
with simply adding a colorbox class with$(this).addClass('colorbox');
* Make colorbox_image_module.js load before colorbox.js, so the above work
* Some performance improvements in colorbox_image_module.js, mainly .image-attach-body -> div.image-attach-body selector, and adding initColorboxImageModule-processed check.
* Adding the image title to the image link so it shows up in Colorbox
If it works well for you I will commit it and make it part of the beta 3 release.
Comment #5
frjo CreditAttribution: frjo commentedComment #6
recrit CreditAttribution: recrit commentedI've tested and everything works, thanks!
I'm still tossing around the lines below from my original js code.
This makes sense since when dealing with a gallery or image attach because all the images are the same derivative. But if the images on the page are mixed derivatives - example: thumbnails, original, preview -- then the original and preview's won't get colorboxed and won't show up in the colorbox gallery slides. Removing these lines can eliminate any of this confusion.
Comment #7
recrit CreditAttribution: recrit commentedChanges to patch:
Comment #8
frjo CreditAttribution: frjo commentedI added some comments, replaced "_original" with IMAGE_ORIGINAL like in the Image module and added/removed a couple of spaces.
Give an OK to it and I will commit it.
Comment #9
recrit CreditAttribution: recrit commentedI believe its OK to commit in this state. This is obviously a weak link with the image module which results in these crazy auto js files...
Some things to note about colorbox_image_module.js :
settings.image_derivative + '.' + extension
... I don't believe this extra work is needed since the original image is most likely the largest.Comment #10
frjo CreditAttribution: frjo commentedCommitted to 6-dev. Thanks again for this excellent contribution to ColorBox!
You are right that the whole colorbox_image_module.js is a bit of a hack. It would be a lot nicer if the Image module could add some Colorbox/Lightbox2 etc. integration.
Comment #11
recrit CreditAttribution: recrit commentednot sure on the etiquette but you could override the image modules theme function all together.... for maintaining you would have to keep up with releases of image module.
I have tested with the code below and it will link the colorbox anywhere image calls theme('image_display'), ie this even works for custom views or anywhere for that matter.
This would go into the colorbox.module:
Comment #12
kiwi_steve CreditAttribution: kiwi_steve commentedJust a thought: Isn't the image module one of Sun's babies? Wouldn't it be better to talk to him (& include him?) and work something out rather than create a cludge that will probably break at some point through the simple fact that he doesn't realise you're working around certain aspects of his module.
Having this work with the Image module is one of the single most-important features for this module IMHO... so I would like to see it developed in the right direction with the right support from the right people - so far so good.
And I'd like to thank everyone who's working on this module - its made a huge difference to the presentation of a couple of sites I'm working on, and I'm learning a bit about how stuff works behind the scenes by reading these posts and trying to follow the code.
2 thumbs up :)
Steve
Comment #13
recrit CreditAttribution: recrit commentedtheme override in #11 causes problems with img_assist and would need to have some conditions before applying the link, ie check if arg(0) == 'img_assist'... this could turn out more troublesome than the js method...
thoughts?
I'm all for a cleaner way of doing this, but from past issues it looks like thickbox was forced to do it this with js.
Comment #14
frjo CreditAttribution: frjo commentedI don't think it’s a good idea to include a theme override in another module. An option is to have instructions in the README so users can do it in their own themes.
There are a setting "Deactivate Colorbox on specific pages" and by default it includes "img_assist*".
The absolutely best would of course be native support built in to the Image module.
I suggest that you who are using the image module and Colorbox module contact joachim and sun and talk about this. Start by making a feature request in the issue queue for the Image module.
http://drupal.org/project/issues/image