I want to have separate width values for the $sizes attribute for the images in the gallery and a separate one for the regular embedded image(s), i.e. images outside the gallery (also not the featured image). Both the regular image(s) and images in the gallery are in the same singular post.

function adjust_image_sizes_attr( $sizes, $size ) {
    if (is_singular('post')) {

        //I want to use these sizes for images in the gallery only
        $sizes = '(max-width: 599px) 50vw, (min-width: 600px) 33vw, 400px';
        
            
        //And these sizes for other embedded images in the post content
        $sizes = '(max-width: 399px) 400px, 1000px';
            
        return $sizes;
    }
 }
 add_filter( 'wp_calculate_image_sizes', 'adjust_image_sizes_attr', 10 , 2 );

Basically, I am trying to use wp_calculate_image_sizes on images inside the image gallery only. How to do that? Or what is a better way to do this?

Thank you in advance for your help.

0

There are 0 best solutions below