• Though my Media settings are left to default (thumbnail 150×150, crop activated), the_post_thumbnail() displays my 1400×1050 featured images cropped to … 940×198.

    None of these values (940 or 198) corresponds to anything : medium, large or real size. The real size is 1400×1050 not 940xsomething. And it doesn’t matter if I re-upload the image or not.

Viewing 6 replies - 1 through 6 (of 6 total)
  • check your theme’s functions.php file and template pages on which you are displaying thumbnails to see if it is setting an incorrect
    set_post_thumbnail_size()

    Thread Starter baia

    (@baia)

    Well it’s a fresh install so everything is at default values. In functions.php, my set_post_thumbnail_size() is set like so :

    set_post_thumbnail_size( HEADER_IMAGE_WIDTH, HEADER_IMAGE_HEIGHT, true );

    You have the thumbnail size set to the size of the header image width and height. In your initial post you said the thumbnails are 940 x 198. That sounds like the dimensions of a header image to me. Try changing it
    from
    set_post_thumbnail_size( HEADER_IMAGE_WIDTH, HEADER_IMAGE_HEIGHT, true );
    to
    set_post_thumbnail_size( 150, 150);
    or whatever size you want the post thumbnails

    Thread Starter baia

    (@baia)

    Now I have sizes like 150×112, 150×120, etc. That is, the cropping doesn’t work (though the crop option is selected in Settings > Media).

    The cropping is also faulty for Medium and Large size as well as custom sizes (using add_image_size) : never do I obtain the fixed size I want.

    And all of this happens in a fresh, default install.

    Most likely the issue with your thumbnails is a setting on the
    dashboard Settings / Media page

    What you are seeing, 150 x 112, sounds like proportional cropping. That is, the height and width are kept in the same ratio as on the full sized image.

    To keep thumbnails with both dimensions at the specified size, make sure the box labeled
    Crop thumbnail to exact dimensions (normally thumbnails are proportional)

    on the dashboard Settings / Media page, is checked.

    The Medium and Large sizes also do proportional cropping as that is what 95% of people want. I don’t know offhand how to make them come out to the exact dimensions specified, if you asked for 400 x 300 and they come out as 400 x 225 to remain in proportion. I suggest googling for something like “WordPress turn off proportional image cropping”. I’m sure there is a way to cause that to happen.

    Thread Starter baia

    (@baia)

    I think what you call ‘proportional cropping’ is actually no cropping at all. The image is visible in its totality inside the dimensions I specified, no cropping occuring there. And yes the option you mentionned is checked as I said.

    Not only did I Google this issue quite a lot, but on this very forum I found many threads on it and no working solution so far.

    Apparently, nobody knows how to fix this basic problem !!

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘the_post_thumbnail() not working’ is closed to new replies.