-
Notifications
You must be signed in to change notification settings - Fork 140
Add picture element support
#73
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
Conversation
@adamsilverstein did you add the hook for the |
The entire PR is for testing. |
|
reopening to bring this PR up to date... |
4392bec to
1ebc2ec
Compare
picture element support
joemcgill
left a comment
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.
This is looking good and surprisingly doesn't seem to impact default styling of images even though the markup changes. Left a couple of questions.
| // If the original mime types is the only one available, no picture element is needed. | ||
| if ( 1 === count( $mime_types ) && $mime_types[0] === $original_file_mime_type ) { | ||
| return $image; | ||
| } |
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.
For sites that don't support AVIF or WebP, if someone uploads an original in one of those formats, won't all the intermediate sizes be JPEG? If so, do we want this to result in using picture or would a simple img element be preferred?
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.
I haven't tested with WebP support missing, but my expectation is that you shouldn't be able to upload a WebP image if your server doesn't support it. This may not be working correctly in the block editor currently, so for now I am referring to uploading in the media library. I'm not sure I have a test version of PHP that doesn't support WebP.
~98% of WordPress sites are on a host that supports WebP so this is an edge case.
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.
@joemcgill - I created this follow up Issue to work on improving the settings screen in particular when WebP isn't supported.
|
I found that the Settings link was pointing to the "Also output JPEG" checkbox: I've fixed this in 2e68884 so that the settings link points to the entire section. |
Co-authored-by: Weston Ruter <[email protected]>
Co-authored-by: Weston Ruter <[email protected]>
Co-authored-by: Weston Ruter <[email protected]>
Co-authored-by: Weston Ruter <[email protected]>
Nice catch! |
westonruter
left a comment
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.
With https://github.com/WordPress/performance/pull/73/files#r1619520322 this looks good to go! 🥳
Co-authored-by: Weston Ruter <[email protected]>
Thanks the reviews and feedback🎉 ! |



Fixes #21
Closes #1236
wp_content_img_tagto potentially wrap (media) images in a picture element.twentysixteen.Picture element and AVIF support by version
AVIF support is being worked on and
pictureelement support can be especially useful for adding AVIFs to your site if you have users on browsers that don't support AVIF.pictureSupport (Version, Date)