WordPress.org

Forums

[resolved] Crop post-thumbnails (3 posts)

  1. robertosalemi
    Member
    Posted 1 year ago #

    I have a problem I have to point out that the images display on a page : I can not cropparle .

    In the functions.php file of my template I have:

    if (function_exists( 'add_theme_support')) {
    	add_theme_support( 'post-thumbnails');
    }	
    
    	if ( function_exists('add_image_size')) {
    		add_image_size( 'full-size',  9999, 9999, false );
    		add_image_size( 'slider',  980, 9999, false );
    		add_image_size( 'portfolio-single',  550, 9999, false );
    		add_image_size( 'small-thumb',  50, 50, true );
    		add_image_size( 'grid-thumb',  230, 180, true );
    	}

    I have to show :

    <?php the_post_thumbnail('grid-thumb'); ?>

    in theory the image should be cropped to a size of 230x180 , but this does not happen .

    Reading in some forums I saw that maybe I should set the image size in evidence directly in the first IF in the file functions.php , so that :

    if (function_exists( 'add_theme_support')) {
    	add_theme_support( 'post-thumbnails');
    	set_post_thumbnail_size( 200, 180, true );
    }

    but still does not work .

    Where is the problem ?

    Thank you.

  2. robertosalemi
    Member
    Posted 1 year ago #

    Maybe ... I have to regenerate all the thumbnails?

  3. robertosalemi
    Member
    Posted 1 year ago #

    Resolved,
    The correct syntax is:

    if (function_exists( 'add_theme_support')) {
        add_theme_support( 'post-thumbnails');
    }    
    
    if ( function_exists('add_image_size')) {
            add_image_size( 'full-size',  9999, 9999, false );
            add_image_size( 'slider',  980, 9999, false );
            add_image_size( 'portfolio-single',  550, 9999, false );
            add_image_size( 'small-thumb',  50, 50, true );
            add_image_size( 'grid-thumb',  230, 180, true );
    }

    Next, I installed the plugin Regenerate Thumbnails (LINK) and regenerated the thumbnails.

Topic Closed

This topic has been closed to new replies.

About this Topic