tags:

views:

43

answers:

1

Here's the section of code from prettyphoto.js that I need to alter. What I am trying to achieve is have each photo have a following hidden div or span that holds the description for the photo. This way I can include html in the description.

Possible?

Thanks!

var images = new Array(), titles = new Array(), descriptions = new Array();
if(theGallery){
 $('a[rel*='+theGallery+']').each(function(i){
  if($(this)[0] === $(_self)[0]) setPosition = i; // Get the position in the set
  images.push($(this).attr('href'));
  titles.push($(this).find('img').attr('alt'));
  descriptions.push($(this).attr('title'));
 });
}else{
 images = $(this).attr('href');
 titles = ($(this).find('img').attr('alt')) ?  $(this).find('img').attr('alt') : '';
 descriptions = ($(this).attr('title')) ?  $(this).attr('title') : '';
}

$.prettyPhoto.open(images,titles,descriptions);
return false;

});

A: 

This should work (untested) as long as the span comes right after the image.

var images = new Array(), titles = new Array(), descriptions = new Array();
if(theGallery){
 $('a[rel*='+theGallery+']').each(function(i){
  if($(this)[0] === $(_self)[0]) setPosition = i; // Get the position in the set
  images.push($(this).attr('href'));
  titles.push($(this).find('img').attr('alt'));
  descriptions.push($(jQuery.sibling(this).next).text());
 });
}else{
 images = $(this).attr('href');
 titles = ($(this).find('img').attr('alt')) ?  $(this).find('img').attr('alt') : '';
 descriptions = ($(jQuery.sibling(this).next).text()) ?  $(jQuery.sibling(this).next).text() : '';
}

$.prettyPhoto.open(images,titles,descriptions);
return false;
}));
Aaron Harun
I tried this, and it broke the prettyphoto functionality.
Jason