Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Image title / alt #300

Open
majkimajki opened this issue Sep 29, 2021 · 4 comments
Open

Image title / alt #300

majkimajki opened this issue Sep 29, 2021 · 4 comments

Comments

@majkimajki
Copy link

Hi,

am I blind, or does FoF Upload not put in alt / title when uploading an image?

Is there anyway you could make it a feature so that let's say the title of the disscusion is put in the alt or title tag?

@clarkwinkelmann
Copy link
Member

clarkwinkelmann commented Sep 29, 2021

There are 3 different templates that render an image:

Image preview template: uses img tag with a title and alt attributes set to the label

<img src="{@url}" title="{@base_name}" alt="{@base_name}"/>

Image: uses a CSS background image, so alt isn't applicable

<div class="wrapper" style="background: url({@url}) center / cover no-repeat">

Markdown: uses the built-in Markdown image tag. I see we hard-coded "Image description" as the default alt value, this was probably done with the intent that the user will modify it. We could probably use the label as the default value here, though since the label is generated from the filename, it might or might not be an improvement depending on the circumstances. We could also keep the alt value blank by default in the Markdown template.

return '![Image description]('.$file->url.')';

Were you referring to one of these 3 situations, or is there another place where the alt value is completely missing?

@majkimajki
Copy link
Author

Hi,

I'm using Upload by FriendsOfFlarum v.1.0.3

In the editor it shows as: upl-image-preview url=https://....jpg

Rendered html gives and output:

img src=".....jpg" title="" alt=""

@clarkwinkelmann
Copy link
Member

clarkwinkelmann commented Sep 29, 2021

Most likely the values will be blank in the preview, but they should be filled in the final render.

You could check what the base_name value is for the file inside of the database (fof_upload_files table). Maybe it's blank because the original filename consists of non-ASCII characters? Or maybe we have something going wrong with the base_name attribute generation?

@majkimajki
Copy link
Author

majkimajki commented Sep 29, 2021

Final render gives, img src=".....jpg" title="" alt="" - missing alt and title.

Both with jph/png, filename tested was, test.jpg so this should not be a problem.

To be honest I do not know what {@base_name} is, will check everything you wrote in the morning.

Is anybody able to replicate this error? I can't seem to find a flarum with FoF upload to check another site.

EDIT: Eg. https://creatorswave.com/d/327-what-do-you-want-to-make/3 gives blank also in rendered html.

Still, from what I understand {@base_name} gives exactly what? The name of the filename?

Maybe, a feature where title = title of disscussion, alt = 3 words from the post content?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants