I have the Thickbox module installed and it is working fine for individual images. However, when viewing an image which is a part of a gallery (based on the image gallery functions as part of the image.module), Thickbox does not treat the images as gallery images. You must open each image separately and then close it to get to the next one.

Is the ThickBox module supposed to automatically act in 'gallery' mode when viewing images which are part of a gallery? If so, it is not working. This is a feature which would really add to the module.

Comments

kleingeist’s picture

HI gmak,

first the module is currently not supposed to support grouping.
This has two connected reasons:

First: At the moment the thickbox_auto.js script leaves the existing links intact. This means the link still points to the image node (example.com/node/3) instad of the direct image url. It just gets an onclick event appended, which calls TB_show() with the correct path to the image.

Second: The core thickbox.js script is looking for links, that points to an image and share the same rel= value, to generate the grouping ("gallery behavior").

So the problem is, that the core script wont find the unmodified "node-links" and thus its grouping functions wont work.

Solution 1: Change the thickbox_auto.js to alter the links. A patch could look like this:

<code>
function TB_drupal_init() {
  var i = $(this).children("img");
  var t = i.title() || i.attr("alt") || null;
  var u = i.src().replace(".thumbnail","");
  var g = "drupal_auto";
  
  // untested quick and dirty grouping hack
  // change links to point directly to the image
  $(this).href(i);
  $(this).title(t);
  $(this).rel(g);

  TB_show(t,u,g);
  this.blur();
  return false;
}

But this has some downsides:
First this piece of code wont distinguish between different galleries if there are more than one. It just adds each picture it founds on one page to this specific category. Maybe this could be changed, but i have no spontaneus idea how to fix this.
Second, there will be no way of going to the image node with browser functions like "Open in new tab/windows", cause each connection has been cut. Originally i hoped it would be possible to extend the thickbox function with a drupal specific link to the nodepage because of comments etc. But the frjo, maintainer of this module, didn't like the idea of hacking the drupal.js core.

So the second possible solution, changing the thickbox.js functionallity of grouping, is also out of discussion.

kleingeist’s picture

urgs... sorry i wanted to click on preview not on submit *blush*.

i just wanted to add:

in my opinion a builtin groupin function would be nice. But to do it right, means restriction automatic grouping to real existing groups like each image in a single node or image category page, would require some more work.

Also i think we should really discuss to extend TB_show with a fourth paramter and add the functionality to create a link like: "Show full node" at the bottom of the caption. Well but this is another issue.

greetings kleingeist

gmak’s picture

kleingeist,

thanks for your response to my message. I think ThickBox is a great module. So far it seems much more stable than Lightbox2 (which had a tendency to crash Firefox randomly).

I tried your 'quick and dirty' hack to thickbox_auto.js, but it doesn't seem to work. You get the first image (the one you clicked) to come up, but it only every has a 'prev' link (doesn't matter where in the sequence of images you start). Clicking on the prev link shows the 'loading' animation but no image is then displayed (you just get the screen greyed down).

I wonder if it is possible to have the gallery feature work in two ways?

1. If there are multiple images that appear on a page (in a node) that they get linked together as a gallery.

2. If you are viewing a gallery page (as generated by the gallery feature of the image.module) the 'gallery' for thickbox is based on the taxonomy term of the image.

Having said the above, I have to admit that my PHP and Javascript are not well enough advanced to be of much coding help, but I'm happy to test and feedback.

Thanks for a great module.

kleingeist’s picture

sorry i currently have no testing system, so i cant say for sure this is will be working, but there to be a typo in my code snippet:

replace $(this).href(i); by $(this).href(u);

when i find some time, ill look if there is a way to distinguish between the context of the different images. but i assume instead of doing this in pure js, it would be easier to handle this by a custom theme, which adds the class="thickbox" and rel="" manually

Deyan’s picture

hi, also have the same issue. tried the patch, what i get is this: the thickbox designates the number of images you have in the gallery in the order that they are clicked. ie if ou have ten images and click on the first and then on the last, first you get "image 1 of 1" and nothing else, then on the last image (which is the tenth) you get "image 1 of 2" and you get a prev button which takes you to image number one. So it's pretty confusing as you can see. Hope you find some time to help out soon.

kleingeist’s picture

Status: Active » Needs work
StatusFileSize
new1.38 KB

sorry, i dont have much time these weeks.
here is another version of thickbox_auto.js which enables "global" autogrouping. This means you can just click thourgh every image on a page. Unfortunately its not context sensitive. This would be possible in theory, but it would allways depend heavily on the used theme. For example, you could first find all node blocks $("div.node"), loop over them .each(function(i) {}) and find each image link within and attach the init $("a [img.img.thumbnail]").not(...).each(function() {TB_drupal_init(this,i)}). Something like this sould work in theorie. I couldnt test it.
Maybe when this semester is over, i can work a little on this, but atm there is no time.
The supplied fix is also far from being perfect, but it does it ob on my testplatform. Please look through for bugs and improvements.

Greets kleingeist

Deyan’s picture

hi, tried the latest thickbox_auto.js that you suggested, but still it doesn't group the images in any way, you still have to open and close each image individually... have no idea why it won't work... I appreciate your time on this though, - thanks.

frjo’s picture

Category: bug » feature
bubu’s picture

Status: Needs work » Needs review

My proposal:

$(document).ready(function() {
  $('a[img.image.thumbnail]' ).not(".thickbox").each(function(){
    var s, v = '.'+thickbox_derivative;
    if ( v == '.original' ) { v = '' };
    $(this).attr('href',$(this).children('img').attr('src').replace('.thumbnail',v));
    $(this).attr( 'title', $(this).children('img').attr('title') );
    if( ( s = $(this).parents('ul.images').siblings('h2').text() ) != '' ) {
      $(this).attr( 'rel', s ); 
    };
    $(this).click(function(){
      var t = this.title || null;
      var g = this.rel || false;
      TB_show(t,this.href,g);
      this.blur();
      return false;
    });
  });  
});
dmf-1’s picture

In a test on 5.1, the proposed change in #9 did not work for me.

kleingeist’s picture

Version: 4.7.x-1.x-dev » 5.x-1.x-dev
StatusFileSize
new3.73 KB

Hi Folks,

finally i found some time to think about this issue and i came up with a new, this time tested, solution.
My current approach is a different one, than before. The old version didn't touch the link itself - it just has bound another event to it. Now the script will only rewrite the links and set the href, title, rel and a class. Everything else is done afterwards by the original thickbox.js script.

Currently the script will group images in nodes and in image galleries, but it could be easily extendend to other contexts. The Image derivate selection is currently disabled due to this issue (http://drupal.org/node/125610) and another bug i just discovered.

Please apply this patch to the current thickbox module and test it with Drupal 5.1 and the latest image module.

Hope this helps,

frjo’s picture

Version: 5.x-1.x-dev » master

Thanks! Committed to HEAD making it easier for people to test.

http://drupal.org/node/96785

t4him’s picture

This worked great for me! I was quite disapointed when i did not have the "prev" "next" after a clean install of thickbox 5.x-1.x-dev. I found this post, installed the head version and it works great.

I have about 70 images that i need to upload. I use the import images from the image module and import them to a specified gallery. With thickbox active, I now have a very fast image gallery browser. Thanks for this Fantastic Module.

t4him

nancydru’s picture

Hmm, I don't see any difference. I replaced the module, disabled it, re-enabled it, and even ran update.php. I still get only one picture at a time.

kleingeist’s picture

this is strange, on my system everything works fine. do you have more than one image listed in the content of one node or inside the image_gallery list? Pictures of different nodes will _not_ be grouped.

Which browser are you using, which version of drupal, thickbox.module and image.module?

- kleingeist

jacoder’s picture

Status: Needs review » Active

This fix is working great for me as well. At first it seemed as if nothing had changed, but then once I closed the browser and reopened and pointed to the page, all was well. I am not sure why it didn't seem to take immediately. Perhaps something to do with the browser cache. Nevertheless, it is working great now. Thanks for sharing!

http://taylorsoutheast.shacknet.nu/image/tid/2?page=1 - see it work here.

my setup:

drupal 5.1
thickbox HEAD
image 1.1.4.1
firefox 2.0
IE 7

frjo’s picture

Thanks very much for the reports and the example site.

I have committed it to the Drupal-5 branch.

nancydru’s picture

Well, I use IE6 and FF2. You can check the live site at http://streamlinefencenc.com.

That site is 5.1.

; Information added by drupal.org packaging script on 2007-02-28
version = "5.x-1.x-dev"
project = "image"

; Information added by drupal.org packaging script on 2007-03-12
version = "HEAD"
project = "thickbox"

nancydru’s picture

Well, I don't know why it would make any difference, but I went and checked it with Netscape and it worked fine. So I went back with FF2 and IE6 and now they work too.

frjo’s picture

I went to http://streamlinefencenc.com/image/tid/34 and Thickbox worked as it should there.

AHolmes-1’s picture

Version: master » 4.7.x-1.x-dev

Can anyone provide some assistance with a fix with 4.7.x? I'm a little too noob to try to tackle this. Thanks.

jjma’s picture

Version: 4.7.x-1.x-dev » 5.x-1.x-dev

The update works well if all your images are on one page but if your gallery spans two or more pages the images for these pages are not included. e.g if there are 20 images on 3 pages of the gallery, the first 20 will show only but not the other 40.

Jon

finedesign’s picture

Title: automatic gallery functions » advice for a PHP dummy
Version: 5.x-1.x-dev » master

Sorry for the ignorance, but I believe this forum should answer my question…I'm just a PHP dummy.

I am using imagecache and imagefield to generate thumbnails for my node images. Each node has multiple images attached. I want to display ALL the thumbs on a page, with each linking to the original in Thickbox.

I cannot find anywhere the code to display ALL the thumbnails attached to a node. I have only found the following, which only displays the first image attached to the node:

print theme('imagecache', 'p3_thumb_img', $node->field_image[0]['filepath']);

Then I found the following, which displays the thumbnail, then in Thickbox displays the full version. Fantastic, but I need ALL my thumbnails connected with the node to show up.

				<?php
				foreach ((array)$field_image as $item) {
				?>
				<?php
				print theme_imagefield_image_imagecache_thickbox('p3_thumb_img', 'Thickbox: thumb', $item['filepath']);
				?>
				<?php
				}
				?>			

Is it possible to:
1) Display a list of all images attached to the node
2) Enable each one so it links to Thickbox
3) No matter which img is clicked, Thickbox will find the other images and add nav between them

I noticed in particular this post above: http://drupal.org/node/106849#comment-211030
but I don't know what I'm supposed to do with the file.

I also downloaded this version of Thickbox but it doesn't appear to change anything:
http://drupal.org/node/96785

finedesign’s picture

Title: advice for a PHP dummy » automatic gallery functions

Yikes…perhaps I don't understand the forums here. It appears I changed the title for the whole forum? I'm now changing it back to the original: "automatic gallery functions"

finedesign’s picture

Fixed. It was not Thickbox's fault.

xav’s picture

Hi,

I just installed ThickBox, and here is my problem: I have a gallery with 119 images, with 60 thumbnails per page. TB works but only displays the first 60 images - see http://parateam.com/image-galleries/sortie-filles-au-sapenay-avril-2007 if you don't understand what I mean.

Is that how it should work, or is there something I didn't configure right ?

I'm using drupal 5.2, image 5.x-1.5 and thickbox 5.x-1.0.

Thanks,
Xav

kleingeist’s picture

Regarding jjma and xavs issue of thickbox only processing the first of multiple image gallery pages: thats how it is supposed to work.
Maybe there is a way to build something, that automatically fetchs more images per ajax, but this hould become another module.

frjo’s picture

Status: Active » Fixed
Anonymous’s picture

Status: Fixed » Closed (fixed)