photobox icon indicating copy to clipboard operation
photobox copied to clipboard

Image caption order or configuration option

Open heliogabal opened this issue 8 years ago • 1 comments

I realized that the caption gets created by either taking the alt or the title attribute into account:

Line 288 in jquery.photobox.js

// if no img child found in the link
                if( thumbImg ){
                    captionlink = thumbImg.getAttribute('data-pb-captionlink');
                    thumbSrc = thumbImg.getAttribute(that.options.thumbAttr) || thumbImg.getAttribute('src');

                    caption.content = ( thumbImg.getAttribute('alt') || thumbImg.getAttribute('title') || '');
                }

IMO it would make more sense to first look for the title, and if that's not filled out use the alt, as alt attribute is required, title optional. Even better would be an option to configure the desired behaviour:

  • use alt, then title
  • use title, then alt
  • use only alt
  • use only title

In my use case, I would want to only use title text as caption, but there are surely other possible uses. Is there a way to do this already? Or would you consider this a feasible enhancement?

heliogabal avatar Apr 23 '16 15:04 heliogabal

well, my original approach was that every person should modify the script to suit their needs, and my job is to make the script as easy to maintain/read as possible so others could easily find the code needed to be changed.

Yeah, I can change it so the title would be looked for first and then the alt attribute, but making the user choose via options seems like there will be no end to the modifications one could do. I get many different requests, and it's not always easy to justify adding custom settings or decide to just leave and and let the users modify it themselves.

yairEO avatar May 02 '16 10:05 yairEO