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

Change method to get label (alt text) of images; avoid double-escaping #810

Merged
merged 2 commits into from
Feb 13, 2022

Conversation

GarrettAlbright
Copy link
Contributor

Fixes #806.

This adds a getLabel() method to the Image node which attempts to get a text representation of the child nodes, and calls it to generate the "alt" attribute for the final <img> tag. This changes the previous approach which involved rendering the children and then extracting the text via regular expressions from the generated HTML. This was also causing special characters in the alt text to be double-escaped.

If you like video games, it may be of interest that Gamer Guides sponsored my development of this fix.

…d hacks and double-escaping of special characters.
@colinodell
Copy link
Member

Thanks for the fix!

I did a little refactoring to move all the logic into the renderer, but otherwise, this looks great to me. I'll fix the unrelated Psalm errors and have this released shortly :)

@colinodell colinodell merged commit 4c7fc5f into thephpleague:2.0 Feb 13, 2022
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

Successfully merging this pull request may close these issues.

Image alt attributes are double-escaped
2 participants