I'm using drupal7 Photoswipe module which uses Photoswipe jQuery plugin to build a view and display a gallery of photos. Currently Photoswipe allows only to display image title as image caption.
Also to display other text fields from the same content node, I add content text fields to the view and change their display to add a CSS class (.photo_text).
Then I modified openPhotoSwipe function within photoswipe.jquery.js to get the image parent html node ($image .parents("td:first") ) and select it's children having the (.photo_text) CSS class, to add them as image title.
openPhotoSwipe: function(index, galleryElement, options) {
var pswpElement = $('.pswp')[0];
var items = [];
options = options || Drupal.behaviors.photoswipe.photoSwipeOptions;
var images = galleryElement.find('a.photoswipe');
images.each(function (index) {
var $image = $(this);
var $eleme = $image.parents("td:first");
var $eleme_class = $eleme.children('.photo_text');
var $photo_text = "";
if ( !!$eleme_class){
for ( var i = 0; i < $eleme_class.length; i++ ){
$photo_text += $eleme_class[i].innerHTML;
}
}else{
$photo_text = "";
}
// end of add
size = $image.data('size') ? $image.data('size').split('x') : ['',''];
items.push(
{
src : $image.attr('href'),
w: size[0],
h: size[1],
title : $image.data('overlay-title') + $photo_text
}
);
})
I'm now wondering if it exists a simplest way to do the same thing without modifying this module?