Making images in post block more responsive with srcset
-
I noticed the “post” block outputs feature images without a srcset which was less than ideal. I’ve got a suggested update to this file:
/public_html/wp-content/plugins/otter-blocks/vendor/codeinwp/gutenberg-blocks/inc/render/class-posts-grid-block.php
Around line 162:before:
$list_items_markup .= sprintf(
‘<div class=”wp-block-themeisle-blocks-posts-grid-post-image”></div>’,
esc_url( get_the_permalink( $id ) ),
esc_url( $thumbnail[0] ),
esc_html( get_the_title( $id ) )
);after:
$list_items_markup .= sprintf(
‘<div class=”wp-block-themeisle-blocks-posts-grid-post-image”>%2$s</div>’,
esc_url( get_the_permalink( $id ) ),
wp_get_attachment_image( get_post_thumbnail_id( $id ), $size, false, [“alt”=>esc_html( get_the_title( $id ))] ),
);If you could integrate that into the block, then next time it is updated, it won’t overwrite my customizations ??
- The topic ‘Making images in post block more responsive with srcset’ is closed to new replies.