-
Notifications
You must be signed in to change notification settings - Fork 165
responsive featured image #450
responsive featured image #450
Conversation
first take on implementing the featured image in an <img> tag to take advantage of srcset (using object-fit)
This is a fantastic PR — thanks @LittleBigThing! What problem(s) should we be looking out for in IE? I expected it to be obvious, but it's actually looking okay for me... I also tested in FF, Safari, and Chrome, and on iOS. It's looking great in all those places. In any case, if we can get any IE bugs sorted out, I'd love to get this in for RC1. |
Try to resize the browser for IE, at some point it is stretching the image. Also, it behaves differently in IE using a portrait image. I’ll look at the implementation in Twenty Seventeen in more detail when I have some time tomorrow... |
the issue for IE should be fixed using @supports
I just updated the PR with a fix for IE. All browsers supporting Benefit
We should probably look at the semantics of the html added. The |
Awesome, thanks again @LittleBigThing. I'll give this a review later today. 👍 |
I think the CSS here could be cleaned up significantly by using |
Did you try it with a small featured image? |
I tested in Safari, FF, Chrome, Edge, and IE11 (with featured images using variety of sizes/orientations) and it's looking great in every case so far. 👍
I'll cc @allancole for thoughts on that, since he may have some thoughts.
Agreed. That could be handled separately though, since this PR doesn't really modify the flexbox styles. Barring those semantic questions, I think this is likely good to go as a first pass. It's a clear improvement to what we've got. 👍 |
I did test that, and they appear near-identically to the way they appear in |
Yup, I think we should add a |
use the twentynineteen_post_thumbnail() function to add the featured image
Just updated the PR to use I checked on Chrome, IE and Edge, haven't noticed any changes. One drawback is maybe that there is now a double check for |
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 went ahead and re-tested — this looks great to me too.
One drawback is maybe that there is now a double check for is_singular() && twentynineteen_can_show_post_thumbnail().
Agreed, but in the absence of a straightforward way to solve for that, I think we can keep it as is for this first pass at the very least. I'm going to go ahead and merge this. Thanks again all your work on this! Think of all the bytes of data you're saving people with this commit! 👏 🎉
I'm not sure I agree. Is this image really content or is it decorative? It feels more decorative to me, but I could see people disagreeing. If it's decorative (which might be why it was implemented as a background image in the first place), then applying From MDN's
|
@mrwweb I agree that it’s a difficult call. In the post list, the same featured image is not a background image. It will probably depend on the use case. The color filter over the image can be disabled, that also makes a difference in visibility. |
Related to #50 and to #181.
First take on implementing the featured image as an
<img>
tag to take advantage of the responsive imagessrcset
attribute (usingobject-fit
). It does not work right now on IE11, but I think we could make it work using @supports and some additional CSS (see Twenty Seventeen).Definitely an enhancement. The benefit would be that smaller images would be loaded on smaller screens instead of the same large image as with a background image.