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

Alt text not being pulled from Statamic Asset Manager #74

Closed
imbwaldo opened this issue Jul 13, 2021 · 15 comments
Closed

Alt text not being pulled from Statamic Asset Manager #74

imbwaldo opened this issue Jul 13, 2021 · 15 comments
Labels
bug Something isn't working

Comments

@imbwaldo
Copy link

I'm using this …

{{ responsive:image alt="{ alt }" }}

Trying to pull in the alt text entered in the asset itself, but it ain't working. Am I doing something wrong, or is this just not what the Responsive Images addon does?

@riasvdv
Copy link
Member

riasvdv commented Jul 14, 2021

Have you tried {{ responsive:image alt="{ image:alt }" }}?

@imbwaldo
Copy link
Author

Thanks, @riasvdv. Tried that and it didn't work. Does that work for you?

@jeremylatham
Copy link

Thanks, @riasvdv. Tried that and it didn't work. Does that work for you?

I'm having the same problem.

@Ceepster14
Copy link

Having the same problem. Interestingly on a blog listing page I'm buiilding, if I use the title i.e. alt="{title}" then the alt tag will contain the blog title, but no joy accessing the alt text entered in the Statamic Asset Manager.

@josephrlee
Copy link

Any updates on a fix for this yet? Thanks!

@BrianLangevin
Copy link

A workaround that I've found for this is to wrap the responsive tag in an asset tag with an id and container lookup.

{{ assets container="assets" :id="image:id" limit="1" }}
    {{ responsive:image :alt="alt" }}
{{ /assets }}

Obviously this solution is far from ideal.

@imbwaldo
Copy link
Author

Thanks, @BrianLangevin. That's some workaround!

@riasvdv riasvdv added the bug Something isn't working label Sep 13, 2021
@riasvdv
Copy link
Member

riasvdv commented Sep 13, 2021

I'll try to take a look at this either this week or next week, a PR with a fix is certainly welcome as well

@codedge
Copy link

codedge commented Nov 12, 2021

Giving it a little bump 😉 .. running into this as well

@spatie-bot
Copy link

Dear contributor,

because this issue seems to be inactive for quite some time now, I've automatically closed it. If you feel this issue deserves some attention from my human colleagues feel free to reopen it.

@josephrlee
Copy link

Just like to give this another bump. Here's another hacky solution I had to come up with that only works for pages with a single image. I set a bunch of fallbacks on the alt tag.

{{ responsive:banner_image ratio="1" sm:ratio="1.5" lg:ratio="1.75" 2xl:ratio="2.25" class="object-cover object-top w-full" alt="{{ banner_image:alt ?? banner_image_seo:alt ?? seo:title }}" }}

@imbwaldo
Copy link
Author

Sorry, @riasvdv. This remains an issue …

@imbwaldo imbwaldo changed the title Baked-in alt text not being pulled in Alt text not being pulled from Statamic Asset Manager Mar 23, 2022
@imbwaldo
Copy link
Author

Hi, @riasvdv.

Would you please reopen this issue? Thanks!

@ncla
Copy link
Collaborator

ncla commented Jul 1, 2022

Hey @riasvdv,

It seems that the issue is still present. I decided to look at this again after some folks were talking about this issue again in #addon-support on Statamic Discord server, and I thought this was fixed too. But unfortunately I could reproduce this issue locally.

There's something funky going with hydration (for lack of better word) I think, if I run toAugmentedArray on the Asset in \Spatie\ResponsiveImages\Responsive __construct, then the alt tag appears as intended. If toAugmentedArray is run only in the ResponsiveTag then it is missing the alt data (or any data from the data property in the asset .yaml file).

Would you kindly reopen this issue once again? Thanks.

@riasvdv
Copy link
Member

riasvdv commented Jul 1, 2022

Please open a new one, if you could add a failing test or a small repo with a test app so I can easily reproduce it that would help a lot as well

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

9 participants