Site logo

Archived topic

Kindly share code

7 replies · Started by Jim on September 16, 2019

Viewing posts 1–8 of 8

1. I should have mentioned this is for the free version too. Which of these two codes is correct?

add_filter( 'generate_blog_image_attributes','tu_variable_image_sizes' );
function tu_variable_image_sizes( $atts ) {
    // Set up our conditional
    if ( is_home() || is_archive() || is_search() || is_tax() ) {
        $atts[ 'width' ] = 740;
        $atts[ 'height' ] = 402;
        $atts[ 'crop' ] = true;
    }

    // Return our options
    return $atts;
}
add_filter( 'generate_blog_image_attributes','tu_variable_image_sizes' );
function tu_variable_image_sizes( $atts ) {
    // Set up our conditional
    if ( is_home() || is_archive() || is_search() || is_tax() ) {
        return 'blog-thumb'; // Already registered thumbnail
    }

    // Return our options
    return $atts;
}

That looks ok.

What if you go ! is_single() for "is not single post"?

This is the only code that worked.

add_filter( 'generate_page_header_default_size', function( $size ) {
   if ( is_home() || is_archive() || is_search() || is_tax() ) {
        return 'blog-thumb';
    }
} );

I want to exclude both single posts and pages, but show the new thumbnail size sitewide for homepage, categories, tags, search page, etc. How will your code look like? The full size image for single posts and pages scales nicely on mobile devices.

Your code should work then :)

Okay, thanks. I can now deploy the test site.

No problem :)

This archived topic is closed to new replies.