However, the pin description for every single pin in the gallery was the same, taken from the page description, which in my case is "quilts by Amy Krasnansky". I wanted to copy the gallery caption for the picture into its pin description. Here's the code I came up with to do that:
<script>
var elements = document.getElementsByClassName('galleryInnerImageHolder');
for (var i=0; i< elements.length; i++) {
var imageLink = elements[i].getElementsByTagName('a');
var descriptionText = imageLink[0].getAttribute('title');
imageLink[0].getElementsByTagName('img')[0].setAttribute('data-pin-description', descriptionText);
}
</script>
I don't have a lot of HTML experience (although I am a programmer) so this may not be the ideal way to do this, but it does work. Just paste it in the footer code for the page which contains your gallery. I put it right before the Pinterest widget code for the hover button (don't overwrite your Pinterest code or you won't have a Save button).
var descriptionText = 'Amy Krasnansky, ' + imageLink[0].getAttribute('title');
That's it. I hope it helps. Consider leaving a comment if it works/doesn't work for you.