WordPress.org

Support

Support » How-To and Troubleshooting » set_post_thumbnail_size() problems

set_post_thumbnail_size() problems

  • Hi, I’ve been googling and searching the forums for the answer why this doesn’t work but all of the solutions I’ve found hasn’t worked.

    What I’m trying to do is to set a thumbnailsize of 225×225 pixels with hard crop and what I’ve tried is the following:

    In my themes function.php I’ve added:

    add_image_size( 'my-thumb-size', 225, 225, true);
    if ( function_exists( 'add_theme_support' ) ) {
    	add_theme_support( 'post-thumbnails' );
            set_post_thumbnail_size( 225, 225, true );
    }

    In my template I’ve tried calling the_post_thumbnail() like this:

    the_post_thumbnail('my-thumb-size');
    the_post_thumbnail()
    the_post_thumbnail('post-thumbnails')
    the_post_thumbnail( array(225,225) )

    but neither works. When using just the the_post_thumbnail() tag i get images of size 125×125 which is the default thumbnail size in the media upload section, but this however differs from the one set in media settings. I’ve also been changing the default sizing in the media settings but this didn’t work either and finally I went for the approach found here in desperation but no luck with that either.

    Anyone know what I’m doing wrong? I’m developing my own theme so changing isn’t really an option.

    Thanks

    /Olof

Viewing 3 replies - 1 through 3 (of 3 total)
  • how to set single thumbnails ? i need help,please help me, thank you.

    esmi

    @esmi

    Forum Moderator

    As per the Forum Welcome, please post your own topic. Posting in a 4 month old existing topic prevents us from being able to track issues by topic. Added to which, your problem – despite any similarity in symptoms – is likely to be completely different.

    <?php
    if ( has_post_thumbnail() ) { // check if the post has a Post Thumbnail assigned to it.
      the_post_thumbnail('my-thumb-size');
    }
    ?>

    Try like this and let us know if any…

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘set_post_thumbnail_size() problems’ is closed to new replies.
Skip to toolbar