miromannino / Justified-Gallery

Javascript library to help creating high quality justified galleries of images. Used by thousands of websites as well as the photography community 500px.
http://miromannino.github.io/Justified-Gallery/
MIT License
1.68k stars 299 forks source link

Get image caption text from image title or separate tag via jquery selector #302

Closed MurzNN closed 5 years ago

MurzNN commented 5 years ago

Is it possible to get image caption text not from image alt attribute, but from title attribute, or separate html tag (via jquery selector)?

jefftucker1952 commented 5 years ago

You can provide your own caption text by including a <div class="caption"> just after the <img> tag.

http://miromannino.github.io/Justified-Gallery/captions/

The script will use the titleattribute if there's no altattribute, but not having an altattribute is bad practice. To get it to use the titleattribute in all cases would take a little quick script-hacking, on line 226 of justifiedGallery.js.

MurzNN commented 5 years ago

I know that empty alt is bad, but in my project alt contains text, but we need to display to user longer text from other field. Thanks, via <div class="caption"> this works well, even with formatting!

jefftucker1952 commented 5 years ago

Yes, I use the explicit caption div - you can load it up with almost anything!