lokesh / lightbox2

THE original Lightbox script (v2).
http://lokeshdhakar.com/projects/lightbox2/
MIT License
6.24k stars 1.77k forks source link

Lightbox2 requires a lot of redundant markup #682

Open belg4mit opened 4 years ago

belg4mit commented 4 years ago

Lightbox2 requires a lot of redundant markup to produce reasonably compliant HTML, specifically data-title and data-alt on the link. That these is supported is great. However, they should be optional (which they are), but if missing and an alt or title is supplied for an enclosed image, these could reasonably be used for the lightbox itself.

In other words, both of these items should be equivalent: <a href="/foo" data-lightbox="bar"><img src="/baz" alt="quux" title="wibble"></a> <a href="/foo" data-lightbox="bar" data-lart="quux" data-title="wibble"><img src="/baz" alt="quux" title="wibble"></a>

Ideally, this abbreviated form would also expand out as well: <a href="/foo" data-lightbox="bar"><img src="/baz" alt="quux"></a> <a href="/foo" data-lightbox="bar" data-alt="quuz" data-title="quux"><img src="/baz" alt="quux"></a>

This arguably is not a bug, but you have no mechanism for feature requests, so I'm submitting this anyway.

lokesh commented 4 years ago

@belg4mit You bring up some interesting ideas around developer convenience:

alt If an alt attribute is specified on the trigger image, that could be reused by the full-size image shown in the lightbox, as most cases, the thumbnail represents the same image, just scaled up. I need to think through the implementation a bit as the trigger could contain more than one image or mixed content, though this is uncommon.

title Having the alt attribute fill-in for any missing title attribute is riskier as the title (aka caption) and the alt attribute values often serve two different purposes, one for screen readers to describe the subject matter of the image and the other a caption for sighted readers to provide complementary information.