Display an Image's alt or title attribute in ligthbox overlay

Instead of displaying the original filename the lightbox overlay should display the alt tag and/or the title tag of the image.

The image name is often not useful at all. (E.g. something like shutterstock_1073920454325.jpg.) Futhermore the filename can’t even be changed later, since a new filename isn’t accepted, as an image already exists in the database using the same SHA1.

5 Likes

There’s a bit of a long story here. You can read the description of the PRs if you’re interested in learning more. Per

https://github.com/discourse/discourse/pull/8286

and

https://github.com/discourse/discourse/pull/8291

If you’re on the latest, you should now be able to change the text that shows in the overlay in the editor

When you upload an image, you’ll get this

![fileName|690x380](upload://zX6AuAdsNWYzcfIT08zVQPgaJbD.png)

You can edit fileName to whatever you want the image overlay to show.

A quick note:

This was always possible but would have required you to know how markdown handles titles

The way to add a title in markdown looks like this

![image alt|690x380](upload://zX6AuAdsNWYzcfIT08zVQPgaJbD.png "image title")

Given that not many people know about this, the first PR above adds the image alt as a fallback before defaulting to the file name. It being a fallback means that if a title is there, then it’s respected, if not, we use the alt.

6 Likes

This topic was automatically closed after 22 hours. New replies are no longer allowed.