[Resolved] Adjusting crop of image thumbnails

Home Forums Support Adjusting crop of image thumbnails

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1157706
    Matthew

    Hi

    I am using the below function to crop the featured images when they are displayed on the archive pages

    add_filter( ‘generate_blog_image_attributes’,’tu_variable_image_sizes’ );
    function tu_variable_image_sizes( $atts ) {
    // Set up our conditional
    if ( is_post_type_archive( ‘figures’ ) || is_tax( ‘figurecategory’) ) {
    $atts[ ‘width’ ] = 300;
    $atts[ ‘height’ ] = 300;
    $atts[ ‘crop’ ] = true;
    }

    // Return our options
    return $atts;
    }

    Which works and crops nicely. But it’s cropping in a position of center center. I would like to crop from the top down.

    I know you can register new image sizes with the below code, but can you do something similar in the above function?
    //* Register Image Sizes
    add_image_size( ‘figurethumb’, 300, 300, array( ‘center’, ‘top’ ) );

    Thanks,
    Matt

    #1157831
    Tom
    Lead Developer
    Lead Developer

    Hi Matt,

    Our current resizer doesn’t work like that, unfortunately.

    However, we’re ditching the current resizer in the next version, so your add_image_size code is the way to go.

    To use it, simply remove your width/height values in the Customizer, and do this:

    add_filter( 'generate_page_header_default_size', function( $size ) {
        return 'figurethumb';
    } );

    This is how the resizer will work in the next version, except you’ll be able to choose figurethumb as the image size in the Customizer.

    Let me know if you need more info 🙂

    #1158056
    Matthew

    Thanks Tom.

    Will live with it for the moment and revisit again when the new version is out.

    Cheers
    Matt

    #1158415
    Tom
    Lead Developer
    Lead Developer
Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.