Site logo

Archived topic

Feature post + 2 columns + specific image sizes

4 replies · Started by Gabriel Giner on March 29, 2018

Viewing posts 1–5 of 5

Hello, I would like to have a featured image on archives, then 2 columns of posts.

If I don't set a specific image size, the two columns use the original image sizes, which is not really optimal for speed load and also the images are so different it doesn't look really good.

If I set a specific image size, let's say 360x200, the featured image takes also that size.

Can we set an image size just for the posts on columns, and leave the featured image on its original size as this one should take the whole width?

Thank you in advance,
Gabriel

.generate-columns-container .featured-column {
float: none;
width: 100%;
}

that doesn't work for me

Hi there,

We could try something like this:

add_filter( 'generate_blog_image_attributes', 'tu_featured_column_image' );
function tu_featured_column_image( $atts ) {
    // Set up our conditional
    if ( ! is_singular() && in_array( 'featured-column', get_post_class() ) ) {
        $atts[ 'width' ] = 500;
        $atts[ 'height' ] = 300;
        $atts[ 'crop' ] = true;
    }

    // Return our options
    return $atts;
}

Working perfectly. Thank you very much!!

You're welcome! :)

This archived topic is closed to new replies.