Responsive Images Resizing Images

The issue I was having was with some conflicting code I had in my functions file (see below). I usually use this code to remove width/height attributes from being hard-coded into the element in the content area. Removing these somehow appears to mess up the new responsive image implementation in WordPress though. As soon as … Read more

How do I make featured images retreived by the_post_thumbnail() responsive?

You can’t combine PHP and CSS in this way, as PHP is server-side and does not know client screen width, while CSS is client-side and does not know server functions. Instead, you could output both image sizes and then use CSS to show/hide them. eg: <div class=”image-thumbnail”><?php the_post_thumbnail(‘thumbnail’); ?></div> <div class=”image-fullsize”><?php the_post_thumbnail(‘full’); ?></div> and CSS: … Read more

How to exclude an image size from the WordPress srcset

WordPress allows you to hook into wp_calculate_image_srcset See Core file on Trac This filter gives you 5 arguments: $sources One or more arrays of source data to include in the ‘srcset’ $size_array Array of width and height values in pixels (in that order). $image_src The ‘src’ of the image. $image_meta The image meta data as … Read more

How can I make wp default gallery responsive?

You can try using css to control the visual layout. I have tested on my dev server and this was successful. @media only screen and ( max-width: 320px ) { .gallery-item {float:left;width:50% !important;} } what we have done is set the column to 50% the total container width when viewing on devices smaller then 320px. … Read more

Responsive Images – Add srcset attributes to custom Images Function

I think wp_get_attachment_srcset() is what you are looking for. $srcset = wp_get_attachment_image_srcset( $image[‘id’], array( 100, 100 ) ); Now you can escape the HTML and use it in your code. <img src=”https://wordpress.stackexchange.com/questions/276972/PATH HERE” srcset=”https://wordpress.stackexchange.com/<?php echo esc_attr( $srcset ); ?>”>