FEATURE: fallback to image alt before filename if there's no title in lightboxes (#8286)

* use image alt as a fallback when there's no title

* update spec

we used to check that the overlay information is added when the image has a titie. This adds 2 more scenarios. One where an image has both a title and an alt, in which case the title should be used and alt ignored.

The other is when there's only an alt, it should then be used to generate the overlay
This commit is contained in:
Joe
2019-11-04 07:15:14 +08:00
committed by Sam
parent 24d4241e35
commit ce0bac7a3d
2 changed files with 65 additions and 3 deletions

View File

@ -426,7 +426,7 @@ class CookedPostProcessor
informations = +"#{original_width}×#{original_height}"
informations << " #{upload.human_filesize}" if upload
a["title"] = CGI.escapeHTML(img["title"] || filename)
a["title"] = CGI.escapeHTML(img["title"] || img["alt"] || filename)
meta.add_child create_icon_node("far-image")
meta.add_child create_span_node("filename", a["title"])