• Hello RICG team. I’m trying to use a custom sizes array when calling the_post_thumbnail.

    I’m able to use custom sizes on the_content without a problem using the code below. I even figured out that it doesn’t have to be placed in functions.php, but if placed at the top of various template files using different size values for each template, it pulls in the unique size values for on that specific template, which is great!

    add_filter( 'tevkori_image_sizes_args', 'benoit_custom_sizes', 10, 3);
    function benoit_custom_sizes( $args, $id, $size ) {
        if ( $size == 'full' ) {
            $args['sizes'] = '(min-width: 768px) 62.2vw, 93.75vw';
        }
        return $args;
    }

    Is there a similar filter/function for editing the sizes array of the_post_thumbnail? As of now, I can see that the plugin works on featured images, but it puts in the default “(max-width: imagewidth) 100vw, image width” sizes array.

    Thanks!

    -Nick

    https://www.ads-software.com/plugins/ricg-responsive-images/

Viewing 1 replies (of 1 total)
  • Plugin Contributor Jasper de Groot

    (@jaspermdegroot)

    Hello Nick,

    That filter was supposed to work with both content images and featured images so to be honest I don’t why it didn’t work in your case. However, we just released version 3.0.0 of the plugin in which a lot has changed. You can now use the wp_get_attachment_image_sizes filter (this is a plugin filter, but will be included in WordPress as from version 4.4) to adjust the sizes value. This will apply to content images and featured images. If you only want to adjust sizes for featured images or want to use a different value for those, you can use the wp_get_attachment_image_attributes filter (this is a WordPress core filter).

    I hope this helps!

Viewing 1 replies (of 1 total)
  • The topic ‘Custom Sizes for Featured Image’ is closed to new replies.