WordPress.org

Ready to get started?Download WordPress

Forums

Caption not Showing (2 posts)

  1. pablogt
    Member
    Posted 6 years ago #

    Hi
    long time using Lightbox 2.04 by Lokesh Dhakar and plugin Peppe Argento as well as Add Lightbox 0.3 by Mdkart. love this three scrpits and how they work together.

    However now in 2.5 it does not show the image caption or alt or desciption...

    Any idea how to fix this...

    I noticed that the new insert image popup dialog writes the code differently... or better yet in a differnet order so this my explain why lightbox is not showing... the title was first in wp2.3 and now is not even there

    wp 2.5:
    a href="http://www.jeunecreation.org/"><img class="alignnone size-full wp-image-393" title="jc" src="http://pablogt.com/blog/uploads/2008/04/jc.jpg" alt="q" width="600" height="432" />

    wp 2.3:
    a title="p1060951.jpg" href="http://pablogt.com/blog/uploads/2008/03/p1060951.jpg"><img src="http://pablogt.com/blog/uploads/2008/03/p1060951.jpg" alt="p1060951.jpg" />

  2. hawkwood
    Member
    Posted 6 years ago #

    I just started using WordPress, so I don't know how it was, but here is the fix:

    In the lightbox.js file, add firstChild as shown below:

    if((imageLink.getAttribute('rel') == 'lightbox')){
    			// add single image to imageArray
    			imageArray.push(new Array(imageLink.getAttribute('href'), imageLink.firstChild.getAttribute('title')));	 // Added firstChild
    		} else {
    		// if image is part of a set..
    
    			// loop through anchors, find other images in set, and add them to imageArray
    			for (var i=0; i<anchors.length; i++){
    				var anchor = anchors[i];
    				if (anchor.getAttribute('href') && (anchor.getAttribute('rel') == imageLink.getAttribute('rel'))){
    					imageArray.push(new Array(anchor.getAttribute('href'), anchor.firstChild.getAttribute('title'))); // Added firstChild
    				}
    			}
    			imageArray.removeDuplicates();
    			while(imageArray[imageNum][0] != imageLink.getAttribute('href')) { imageNum++;}
    		}

    Also, if you want the image's caption instead of the title, change both the 'title's to 'alt's in the same changed lines.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags