4,114
edits
No edit summary |
No edit summary |
||
Line 25: | Line 25: | ||
var imageElem = $(this).find(imageClass + ' img'); | var imageElem = $(this).find(imageClass + ' img'); | ||
if (imageElem.length) { | if (imageElem.length) { | ||
var captionText = $(this).find('.caption' + imageClass).text(); // Fetching caption text | |||
cardImages.push({ | cardImages.push({ | ||
link: $(this).find(imageClass + ' a').attr('href'), | link: $(this).find(imageClass + ' a').attr('href'), | ||
src: imageElem.attr('src'), | src: imageElem.attr('src'), | ||
alt: imageElem.attr('alt'), | alt: imageElem.attr('alt'), | ||
caption: | caption: captionText, // Storing caption text | ||
captionClass: 'caption-image' + i | captionClass: 'caption-image' + i | ||
}); | }); | ||
} | } | ||
} | } | ||
// Set up image toggle if more than one image is found | // Set up image toggle if more than one image is found | ||
Line 136: | Line 137: | ||
return '<div class="image-container">' + | return '<div class="image-container">' + | ||
'<img src="' + image.src + '" alt="' + image.alt + '">' + | '<img src="' + image.src + '" alt="' + image.alt + '">' + | ||
'<div class="' + image.captionClass + '">' + image.caption + '</div>' + | '<div class="' + image.captionClass + '">' + image.caption + '</div>' + // Using caption text | ||
'</div>'; | '</div>'; | ||
} | } |