Integrated & Settings for Lightbox, Thickbox, Enhanced Thumbnail generation, Altering the image gallery layout + extras
| Project: | Node Images |
| Version: | 5.x-1.x-dev |
| Component: | Code |
| Category: | task |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | needs review |
Jump to:
OK, so it's not a patch, it's the whole module - there were too many things to roll a patch..
I have incorporated a number of things into this module (listed below), along with extra settings to control them. You can now switch between lightbox, thickbox and node images default display for the thumbnails on the admin/settings/node_images page. Lightbox2 and thickbox only become options when they are installed. The display switches back to default if the modules are disabled but the setting isn't changed.
All you need to do to get the functionality of these extra modules is download them, enable them and follow the instructions in the readme.txt for each module (especially lightbox2 which needs extra downloads). You do not need to put any extra js into the node_images folder, keep it all in the respective module folders.
Extensibility:
I implemented the theme_node_images_thumb function from ray007 (http://drupal.org/node/139349) but modified it to be as follows:
function theme_node_images_thumb_default(&$node, &$image, &$parameters) - default (built in) thumnail operation
function theme_node_images_thumb_lightbox2(&$node, &$image, &$parameters) - thumbnails with lightbox
function theme_node_images_thumb_thickbox(&$node, &$image, &$parameters) - thumbnails with thickbox
i also added a function _node_images_get_display_options() which returns a list of enabled display handlers. If you install lightbox2 or thickbox, then their options automatically become available. Adding new display handlers is as simple as adding the lines
if (module_exists('superdisplayhandler')) {
$ret += array('superdisplayhandler' => t('Sooper Dooper Display'));
}to the _node_images_get_display_options() function and adding the associated function
function theme_node_images_thumb_superdisplayhandler(&$node, &$image, &$parameters) {
...whatever...
}to handle the appropriate superdisplayhandler thumbnail code - this is usually just one line.
I also rolled in a couple of other things because I needed them. They are listed below. One of the things I added was a control on the settings page to control where the node body is displayed on the node_images (image gallery) page. It defaults to the bottom, as per the module settings without this addition, but you can now put it at the top or get rid of it altogether.
Altogether, then, the module incorporates code and patches from the following issues:
* H3rnand3z & ray007 ('please help with thickbox modification' - http://drupal.org/node/139349)
* mad-admin & soflete ('Integrate with lightbox' - http://drupal.org/node/116515)
* Vallenwood ('Highly Enhanced Thumbnail generation - supersedes "Keep fixed thumnail size" - http://drupal.org/node/147538)
* terrybritton ('Altering the image gallery layout.' - http://drupal.org/node/135572 - *you will need his css file*)
* subspaceeddy ('div not closed in theme_node_images_gallery($element)' - http://drupal.org/node/145220)
* also further modifications by subspaceeddy to switch between lightbox, thickbox and default, and an ability to alter position of node body on 'Imaqe Gallery' page.
If you are using this version of the module, remember to get terrybritton's updated css file from http://drupal.org/node/135572. It does work without it though.
To install this module, rename your existing node_images.module to node_images.old (so you can switch back if you need to ;) and download this module into your node_images folder. Rename the module to get rid of the .txt extension. No essential database tables are modified so it is easy to switch back.
Let me know if this is of any use for anyone.
Also: I think that the thumbnail output stuff could probably be done more 'drupally' with a 'module_implements' call so that this module would not need to be modified to incorporate new display functions, but for now, this will do...
| Attachment | Size |
|---|---|
| node_images.module_0.txt | 41.05 KB |

#1
ooops... and don't forget to get rid of the _0 when renaming the module :)
I probably shouldn't have uploaded the entire module and am probably breaking all sorts of etiquette rules. I hope you don't mind, it's just that I don't have a great deal of time and wanted to share sooner rather than later.
#2
hey thanks subspaceeddy this version of the module worked well for me...using thickbox.
did have to make a slight alteration to line 652 to stop it causing errors when being validated
return '<a href="' . file_create_url($image->filepath) . '" title="' . $parameters['desc'] . '" class="thickbox" rel="node_' . $node->nid . '">'.$parameters['thumb'].'</a> ';was previously not adding quotation mark after 'rel=' and also had an extra closing tag.
#3
This version of the module works well from the short time that I have been testing it. subspaceeddy do you plan to patch these features into the release version of the module?
#4
I haven't looked at the module for quite some time now and should revisit this. If there is support for these features to become part of the module (stefano?) then I will roll out a new patch for the latest version. Just to say that these features 'degrade gracefully' i.e. they only appear on the settings page if the user has thickbox or lightbox installed and without them the module appears as normal. Let me know....
Right now I'm off on a trip until the 10th so it wouldn't be until then that I could do it.
#5
Thanks to everybody for the updates to the node_image.module. I'm trying to get it to work but I'm getting some effect that I would like to get straight. For example, my images do not have a fixed width and the listing of the thumbnails is not what I want. I would like the previews to remain fix and the thumbnails to be listed in four (4) columns and no more than 6 rows. I have looked into nod_images.module, node_images.css, page-layout.css but I'm still in the clouds. Any suggestions on how to get this right? The work in progress is at http://staging.rocloop.com/node/4723/image_gallery
Thank you in advance.
#6
I think I figure out what the problem was. It had to do with node_image.css.
Thanks -
#7
subspaceeddy if you do patch these features into the Node Images you might also consider one more feature, the ability to configure the addition of images as part of the node creation workflow or via the tab as it currently is. The two step process is just a little to much for the average blogger etc.
#8
Does this module change still work? it's not working for me with lightbox2...