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

Picture element images: Add missing alt text #1319

Merged
merged 12 commits into from
Jul 9, 2024

Conversation

devansh016
Copy link
Contributor

Summary

  • Add alt text to original_image_without_srcset variable which was missing.

Fixes #1315

Relevant technical choices

For maintainers only, please make sure:

  • PR has a [Type] label.
  • PR has a plugin-specific milestone, or the no milestone label if it does not apply to any specific plugin.
  • PR has a changelog-friendly title, or the skip changelog label if it should not be mentioned in the plugin's changelog.
    -->

Copy link

github-actions bot commented Jun 25, 2024

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: devansh016 <[email protected]>
Co-authored-by: thelovekesh <[email protected]>
Co-authored-by: westonruter <[email protected]>
Co-authored-by: adamsilverstein <[email protected]>
Co-authored-by: mukeshpanchal27 <[email protected]>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@mukeshpanchal27 mukeshpanchal27 added [Type] Bug An existing feature is broken [Plugin] Modern Image Formats Issues for the Modern Image Formats plugin (formerly WebP Uploads) no milestone PRs that do not have a defined milestone for release [Module] Picture Element Issues for the Picture Element module labels Jun 25, 2024
Copy link
Member

Choose a reason for hiding this comment

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

It might need some test cases to be written/updated?

Copy link
Member

@mukeshpanchal27 mukeshpanchal27 left a comment

Choose a reason for hiding this comment

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

Thanks @devansh016 for working on it. Left one question and code suggestion.

plugins/webp-uploads/picture-element.php Outdated Show resolved Hide resolved

return sprintf(
'<picture class="%s" style="display: contents;">%s%s</picture>',
esc_attr( 'wp-picture-' . $attachment_id ),
$picture_sources,
$original_image_without_srcset
$image
Copy link
Member

Choose a reason for hiding this comment

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

@adamsilverstein As a fallback image, we should return the original image. In this MDN documentation, they return the original image instead of mime-type-specific images.

I couldn't find proper documentation for this. What do you think?

Copy link
Member

Choose a reason for hiding this comment

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

Yes, I think this is right.

Also, I think the source being generated for 'image/jpeg' can also be removed as well, because if the browser doesn't support AVIF/WebP then it can just fall back to the img which is a JPEG.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

$enabled_mime_types = (array) apply_filters(
'webp_uploads_picture_element_mime_types',
array(
'image/avif',
'image/webp',
'image/jpeg',
),
$attachment_id
);

Should we remove line 61 for the same.

Copy link
Member

Choose a reason for hiding this comment

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

I think we can open a separate PR for this issue to avoid complicating the current one. This will allow us to address it more effectively.

Copy link
Member

@westonruter westonruter left a comment

Choose a reason for hiding this comment

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

LGTM

plugins/webp-uploads/tests/test-picture-element.php Outdated Show resolved Hide resolved
Co-authored-by: Weston Ruter <[email protected]>
@westonruter westonruter merged commit 37e6882 into WordPress:trunk Jul 9, 2024
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Module] Picture Element Issues for the Picture Element module no milestone PRs that do not have a defined milestone for release [Plugin] Modern Image Formats Issues for the Modern Image Formats plugin (formerly WebP Uploads) [Type] Bug An existing feature is broken
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Picture element images: Missing alt text
5 participants