-
Notifications
You must be signed in to change notification settings - Fork 143
Picture element images: Add missing alt text #1319
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
Changes from all commits
2aca958
3895dc3
d73fa78
5f8a6ad
16fcca0
ed39189
d529d9a
3d6d3fe
7d4e568
49648e6
7329e54
04374f8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -131,24 +131,10 @@ function webp_uploads_wrap_image_in_picture( string $image, string $context, int | |||||||||||||||||||
| ); | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||
| // Fall back to the original image without a srcset. | ||||||||||||||||||||
| $original_sizes = array( $image_src[1], $image_src[2] ); | ||||||||||||||||||||
| $original_image = wp_get_original_image_url( $attachment_id ); | ||||||||||||||||||||
| // Fail gracefully if the original image is not found. | ||||||||||||||||||||
| if ( false === $original_image ) { | ||||||||||||||||||||
| return $image; | ||||||||||||||||||||
| } | ||||||||||||||||||||
| $filter = static function (): bool { | ||||||||||||||||||||
| return false; | ||||||||||||||||||||
| }; | ||||||||||||||||||||
| add_filter( 'wp_calculate_image_srcset_meta', $filter ); | ||||||||||||||||||||
| $original_image_without_srcset = wp_get_attachment_image( $attachment_id, $original_sizes, false, array( 'src' => $original_image ) ); | ||||||||||||||||||||
| remove_filter( 'wp_calculate_image_srcset_meta', $filter ); | ||||||||||||||||||||
|
|
||||||||||||||||||||
| return sprintf( | ||||||||||||||||||||
| '<picture class="%s" style="display: contents;">%s%s</picture>', | ||||||||||||||||||||
| esc_attr( 'wp-picture-' . $attachment_id ), | ||||||||||||||||||||
| $picture_sources, | ||||||||||||||||||||
| $original_image_without_srcset | ||||||||||||||||||||
| $image | ||||||||||||||||||||
devansh016 marked this conversation as resolved.
Show resolved
Hide resolved
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, I think this is right. Also, I think the
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. performance/plugins/webp-uploads/picture-element.php Lines 56 to 64 in 1ed2fbd
Should we remove
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||||||||||||||||||||
| ); | ||||||||||||||||||||
| } | ||||||||||||||||||||
There was a problem hiding this comment.
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?