Skip to content

Asset data is not being hydrated correctly causing alt text to be filename instead #143

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

Closed
ncla opened this issue Jul 2, 2022 · 4 comments

Comments

@ncla
Copy link
Collaborator

ncla commented Jul 2, 2022

As requested, separate issue for the alt text issue. This is continuation of this issue. #74

I have created a minimal bug report repository to reproduce the issue. https://github.com/ncla/responsive-image-alt-bug-report

The steps are simple, for blank Statamic install:

  1. Add responsive field to page blueprint
  2. Upload image for responsive field on the "Home" page and save
  3. Through assets browser, open the image you uploaded and edit the alt text
  4. In home.antlers.html just do {{ responsive:image }}

You should see that the alt tag text is output from the filename itself.

The alt text is clearly saved, you can verify that through the asset .yaml file.

data:
  alt: "Don't believe his lies"
size: 706225
last_modified: 1656752941
width: 828
height: 563
mime_type: image/png
duration: null

Rias, let me know if you can reproduce this issue, if not I will try to adjust the repo to get it working.

@ncla
Copy link
Collaborator Author

ncla commented Jul 2, 2022

What's very confusing to me is that a $asset->meta() dump in ResponsiveTag class does not contain asset data, while the same dump in Responsive class does contain the data.

ResponsiveTag
image
Responsive
image
Dumps on the frontend
image

Additionally in my opinion the current it_uses_an_alt_field_on_the_asset test should be rewritten (or a new test should be written) to hydrate asset data automatically from asset meta .yaml file, like in real scenario, and then assert if alt text matches.

@ncla ncla mentioned this issue Jul 2, 2022
@ncla
Copy link
Collaborator Author

ncla commented Jul 2, 2022

Weirdly that one line fix in the #144 PR does it for me, I get alt text just fine. I do not know how to write a test for it yet though. I see some examples for testing this sort of thing in statamic/cms repo https://github.com/statamic/cms/blob/3.3/tests/Assets/AssetTest.php#L422 but I couldn't get the tests to read the meta data from the .yaml file automatically.

@ncla
Copy link
Collaborator Author

ncla commented Jul 4, 2022

FYI for anyone checking this issue: v2.12.4 was published today with the fix, and one of the two folks in Discord server reported back and said that the fix in the PR fixed this issue.

@riasvdv
Copy link
Member

riasvdv commented Jul 4, 2022

Thanks for confirming, forgot to comment here about the release

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

No branches or pull requests

2 participants