I want to make WordPress images responsive, I have read many articles, but I am facing problem with mobile responsive.
This is the code I use :
function blog_2( $attr, $attachment, $size ) {
$attr['sizes'] = '(min-width: 1025px) 1118px, (min-width: 768px) 985px, 95.45vw';
return $attr;
} add_filter( 'wp_get_attachment_image_attributes', 'blog_2', 10, 3 );
<img width="1920" height="1080" src="https://wsite.com/wp-content/uploads/2022/12/blog-10.jpg" class="attachment-full size-full" alt="" loading="lazy" srcset="https://wsite.com/wp-content/uploads/2022/12/blog-10.jpg 1920w, https://wsite.com/wp-content/uploads/2022/12/blog-10-728x410.jpg 728w, https://wsite.com/wp-content/uploads/2022/12/blog-10-985x555.jpg 985w, https://wsite.com/wp-content/uploads/2022/12/blog-10-1118x629.jpg 1118w" sizes="(min-width: 1025px) 1118px, (min-width: 768px) 985px, 95.45vw">
In mobile mode, I want it to be loaded in size 728x410, but when I test on pagespeed site, I see that it is loaded in mobile size 985x555, This has bothered me a lot, Friends, do you have experience in this field to guide me?