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

Ensure default avatars get alt text #147

Merged
merged 2 commits into from
Aug 29, 2022
Merged

Ensure default avatars get alt text #147

merged 2 commits into from
Aug 29, 2022

Conversation

dkotter
Copy link
Collaborator

@dkotter dkotter commented Aug 26, 2022

Description of the Change

In #127 we ensured that if an image that was set as an avatar had alt text associated with it, that alt text would be output. But if someone doesn't have a custom avatar set and instead we use a default avatar, that still doesn't output alt text.

This PR fixes that by:

  1. Setting default alt text that will be used if no alt text can be found (defaulted to Avatar photo with a new filter around that so it can be changed)
  2. If the default avatar being used was uploaded (instead of a default gravatar image) we try and pull the alt text from that image, if it exists. If not, we use the default mentioned above

Closes #146

How to test the Change

  1. Ensure you're using a theme that outputs avatars
  2. Set a default avatar to be one of the Gravatar options
  3. Go to a post that was authored by someone without a custom avatar set
  4. Inspect the source of the avatar and note the alt text should be showing Avatar photo
  5. Change the default avatar to be an uploaded image that has alt text set
  6. Inspect the source again and note the alt text should now be what was set on that image
  7. If desired, test the simple_local_avatars_default_alt filter to ensure you can change the default alt text

Changelog Entry

Added - If a default avatar image is used, ensure that outputs alt text. This will either be default text (Avatar photo) or the alt text from the uploaded default image

Credits

Props @dkotter

Checklist:

  • I agree to follow this project's Code of Conduct.
  • I have updated the documentation accordingly.
  • I have added tests to cover my change.
  • All new and existing tests pass.

@dkotter dkotter self-assigned this Aug 26, 2022
@dkotter dkotter requested a review from faisal-alvi August 26, 2022 21:00
Copy link
Member

@faisal-alvi faisal-alvi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • ✅ Code LGTM
  • ✅ Working as expected.
  • ✅ Issue re-generated in the develop branch:

image
image link

  • ✅ Default alt text:

image
image link

  • ✅ Alt text from image:

image
image link

@dkotter dkotter added this to the 2.6.0 milestone Aug 29, 2022
@dkotter dkotter merged commit dc1f228 into develop Aug 29, 2022
@dkotter dkotter deleted the fix/146 branch August 29, 2022 14:13
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.

Ensure alt text is output when using a default avatar
2 participants