Add custom sizes attributes to responsive images #254
Add custom sizes attributes to responsive images #254
Conversation
…l displayed size, not only full viewport width. Handles both content images and featured images. Reworked from Twenty Sixteen.
function twentyseventeen_content_image_sizes_attr( $sizes, $size ) { | ||
$width = $size[0]; | ||
|
||
//if ( 'page' === get_post_type() || ( ! is_active_sidebar( 'sidebar-1' ) && is_single() ) ) {} |
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.
Getting a minor formatting error here - No space found before comment text; expected "// if (..."
It looks like it's commented out code - if that's the case, it can just be removed instead. Thanks!
Thanks for this PR, @mor10! I noticed a couple small things I wanted to run by you: First, I get a bit of a gap for image sizes for the https://cloudup.com/czv9khWU2q6 What do you think about rolling that one together with the
From what I can tell, Second, when pages are set to use the one column layout in the Customizer, the max image size is 580px: https://cloudup.com/c-IHFWln_EV If a check for Just let me know if you have any questions at all about the above, and thanks again for this work! |
… for page layouts and sets the right sizes attributes for featured images on index pages.
@laurelfulford I've updated the PR with the following:
|
|
||
if ( is_active_sidebar( 'sidebar-1' ) || is_archive() || is_search() || is_home() || is_page() ) { | ||
if ( ! ( is_page() && 'one-column' === get_theme_mod( 'twentyseventeen_page_options' ) ) ) { | ||
767 <= $width && $sizes = '(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px'; |
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.
The theme_mods
had their prefixes removed in #23 - twentyseventeen_page_options
just needs to be switched to page_options
and this should be good!
Thanks @mor10! Added a comment for one small issue, but that should be it! 🙂 Also, to verify - is your WordPress.org username mor10 as well? |
I'll update the prefix. And yes, my username is mor10 pretty much everywhere. |
Thanks @mor10! |
Adds control of
sizes
attribute in responsive images to reflect actual displayed size, not only full viewport width. Fixes #120