This project is very helpful for beginners like me. Thanks.

Now, coming to the issue: I define Title for the image and it appears on the image displayed on the page. I have setup my website to display the image in colorbox when I click the image to view full image. However, the colorbox does not display the title (caption); instead I see something like: Flowers Image 1, Flowers Image 2, etc. ( Image Please see the attached files. Do I need to configure something somewhere to show the captions or it is a feature not implemented yet?

Comments

xaverx’s picture

subscribe

bkmarsh’s picture

subscribe

DRIVE’s picture

Component: Miscellaneous » Code
Priority: Normal » Critical
Status: Active » Needs work
Issue tags: +Image Caption
StatusFileSize
new111.83 KB

In /sites/all/modules/galleryformatter/galleryformatter.module

Current 7.x.1.0 code starting from line 202:

    if ($settings['link_to_full'] == TRUE) {
      /* @TODO
       * doesnt work yet
      $vars['gallery_style'] = 'galleryformatter-view-full '; // give the gallery a class for themers to play with
      * */
      $link_attributes = array(
        'title' => $title,
      );

"TODO" and "doesn’t work yet" were self explanatory to me :)

Without getting all fluffy on you, I got sidetracked on this issue and came up with a solution that should work for any of the other Modals that GalleryFormatter supports.

I am displaying my Galleries with Views and using Colorbox for the Modal and it works great.

----------- use code below ---------------

    if ($settings['link_to_full'] == TRUE) {
      /* @TODO
       * doesnt work yet
      $vars['gallery_style'] = 'galleryformatter-view-full '; // give the gallery a class for themers to play with
      * */
      $link_attributes = array(
        'title' => $item['title'],
      );

--------- use code above -------

	    //'title' => $title, -- Aint gunna happen. $title in this case is the node title so the fallback
		//						is to use that in your modal (thickbox, colorbox etc) with the Image 1 or 
		//						whatever appended to it (it is sticking it in the title value for href).
		// 						^Up at line 66 "foreach ($items as $delta => $item){" gets all of the info 
		//						assigned to all images in your gallery. The <img src.... gets loaded with
		//						both title and alt but the <a href.... was getting the Node title so the below
		//						gets each title for each image in puts in into the link which is what sends
		//						your modal the correct title. So links have the image's title and the images
		//						have both the images title and its alt value so yer covered on XHTML, 509 ~ purety.
		//						DRIVE - 0212201109:36:44

Can't say enough great things about GalleryFormatter. Now that I have my head around some of its possibilities I can see that some of the stuff just needs reworking probably due to Drupal 7. If I understand correctly thus far, because key elements like CCK, Image etc. made it into the core for 7 this module just needs to standardize, sanitize and organize a little bit. I am not taking that on but hopefully my crude workaround will spark "the real" way to do it and the small issues will go away with the next release.

THANK YOU VERY MUCH FOR THIS MODULE. IT IS VERY USEFUL

I am not new to writing code but am new to Drupal and have a lot of bad coding habits that I need to get rid of :)
For now I am focusing on the theming aspect of Drupal 7 (my new theme is nearly ready).

I take criticism, compliments, money or whatever :D .... if it helps the overall deal it's all good. I figured since I was chasing ghosts between Colorbox and GalleryFormatter for the past couple hours, I would spend more time with my thoughts..... hope this is useful to ya's....

later :)

tax14’s picture

DRIVE,

Thanks for providing the fix. It works.

As you have mentioned, this is a great module and very easy to implement. Hats off to the module developers!

manuel garcia’s picture

Version: 7.x-1.0 » 7.x-1.x-dev
Category: support » bug
Priority: Critical » Normal
Status: Needs work » Needs review
StatusFileSize
new2.26 KB

OK, seems like we had a bit of a mess after the migration on this issue.

Please test the patch attached, which solves the problem, and keeps some consistency in the code for maintainability.

DRIVE’s picture

Thanks for the patch.
It works as prescribed -- In full view it uses Title, Alt or File Name no problem.

For slides though, if no Title exists, no caption is displayed... not the alt or the file name. You can decide what the status should now be. I think if people are too lazy to provide alt and title they probably dont care about slide captions... haha.... it would make it pure though ;)

I just dont have time right now to go into that one but figured I'd test your patch since you were nice enough to provide one so quickly.

Thanks for the code lesson as well :) I understand your rewrites and I also use a lot of stuff you built. I read all your tutorials a few times and studied the code.... great stuff! Hey, congrats on your new addition too! :)

manuel garcia’s picture

Status: Needs review » Fixed
Issue tags: -Image Caption

Thanks for testing DRIVE, I've just committed the patch.

About whether or not to display the ALT as the caption, it's up for discussion. Technically it's not meant to be used like that, but well I can see the benefit. Let's discuss it in a new issue to keep things clean.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.