Skip to content

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 <devansh2002@git.wordpress.org>
Co-authored-by: thelovekesh <thelovekesh@git.wordpress.org>
Co-authored-by: westonruter <westonruter@git.wordpress.org>
Co-authored-by: adamsilverstein <adamsilverstein@git.wordpress.org>
Co-authored-by: mukeshpanchal27 <mukesh27@git.wordpress.org>

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 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.


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

Co-authored-by: Weston Ruter <westonruter@google.com>
@westonruter westonruter merged commit 37e6882 into WordPress:trunk Jul 9, 2024
@westonruter westonruter added no milestone PRs that do not have a defined milestone for release and removed no milestone PRs that do not have a defined milestone for release labels Aug 16, 2024
@westonruter westonruter added this to the webp-uploads 2.0.2 milestone Aug 16, 2024
@westonruter westonruter removed the no milestone PRs that do not have a defined milestone for release label Aug 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[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
6 participants