-
Notifications
You must be signed in to change notification settings - Fork 107
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
Enable <picture> element support #21
Comments
I've been digging into how images are stored and generated a bit further and will post an update here soon with a proposed path forward. |
I started working on a POC in a branch, PR incoming. Some good reading:
Some additional details about my findings and the approach: Use cases for implementing the
|
|
Hey @ddur, thanks for the questions:
Good point, we probably want to let themes opt into the behavior so they can adjust CSS accordingly. We could make opting in as simple as checking Good question that needs more research; I'm guessing you would need to apply to the |
Reading up on the various possible uses for the picture element here: https://dev.opera.com/articles/responsive-images/ I created a demo pages with A few notes:
|
@adamsilverstein is this something you are continuing to work on once back from the break? If so, could we assign the ticket to you please? |
How about 'img' element and loading=lazy attribute? Does it apply to picture-source elements? |
@ddur great questions!
Good point, this has been raised before. One approach would be an opt-in approach for the progressive enhancement, themes would declare support for 'picture-element' to get the auto-feature for multiple mime types. Alternately, any theme or plugin could call Our main initial use case for this will be images with multiple mime types (for example AVIF with jpeg fallback), however we need to ensure other use cases (for example varying density or art direction) are also covered by the approach we choose. I'm not sure, this needs more investigation and likely a developer note to show how to properly apply css when using the
Yes it does, according to this it is sufficient to set the attribute on the contained |
I have self assigned, however this is a large task and could use several developers working on it, I will think about how we can break out smaller tasks. |
As per MDN:
So the |
@adamsilverstein @jjgrainger updating this issue to be a [Type] Overview as it will act as our main "epic" issue, and we will create sub-issues once we have finalised an approach. Does that work for you? |
In relation to supporting the picture element in core, I wonder how many WordPress sites already use it? I'm sure some plugins or themes must already use the Maybe @rviscomi can help here to build a query similar to the one we worked on for WebP usage by WordPress version [script], this time looking for |
5% of WordPress sites use the Query
|
@adamsilverstein I will take a look at this for you!
|
Hi folks! I've been working on a high-level proposal for images along with @adamsilverstein - Im hoping it covers some, if not all of the topics brought up in this thread. That being said we are most definitely looking for community feedback, insight and input. The SummaryThe proposal (attached below) provides high-level insight into the behaviour and possible implementation of the
ProposalThe proposal document can be found here: https://docs.google.com/document/d/1XX9QERfakIbE55oai5OmDzbDoxOtpo1aKAA7b0cUONs/edit# AimLet's keep the conversation going so we can nail down an approach to this work and start development! |
How well does this article still hold up today? Even here mentions using srcset for resolution/bandwidth cases. Here's a use real use case I run into and wondering if picture element would help with this: I work with a marketer who provides me images so I can upload them as a featured images for articles. The single article template has a blown up big version of the featured image while the recent news block or archives page template shows multiple articles with thumbnail sized images. Sometimes they are cut off/cropped on smaller screen sizes. Would using picture element help in these cases? Also I'm wondering if anyone knows why the picture element is so underused, was it due to IE11? I checked some random sites to see if they use picture and none of them are using it: https://www.smashingmagazine.com/ |
@LukaszJaro https://www.smashingmagazine.com/ does use the picture element. I see it on the author's pictures. |
@LukaszJaro - I think the biggest issue with the The picture element would essentially allow you to create as many crops as you like that would meet different conditions. You could have portrait on mobile and landscape on desktop, without the need to feature detect or show/hide images with CSS. The browser makes the call based on the conditions provided in |
On reference to the article - I think its sound. WP already attempts to solve responsive images using |
We've been using I've never been a fan of the For the most part we use this as an upgrade to WebP for users, but we occasionally use it for art direction and then almost always to crop hero images. I think the hardest leap for people from a styling perspective is that they need to consider the |
Cross-posting with #996 (comment):
Update: It turns out that descendant selectors targeting |
Current in progress PR: #73
Related trac ticket: https://core.trac.wordpress.org/ticket/42920
See this comment for a detailed description: #21 (comment)
Original description:
Use picture element to enable modern formats like AVIF with fallback to more widely supported format like WebP or JPEG, including responsive srcset markup like current images. Issue - adamsilverstein/modern-images-wp#1 . references: The anatomy of responsive images - JakeArchibald.com & markup: I just want an image on my page
A good initial test case for this feature would be generating WebP images and JPEG images on upload, then using the picture element to specify the WebP with JPEG as the fallback. Although this scenario isn't likely to be that useful, it will set the path for the same approach with other formats.
The text was updated successfully, but these errors were encountered: