Alexander Myrvold
Alexander Myrvold

Reputation: 7

the_post_thumbnail $size not working

I worked for this organization who hired a design company to design there site. We have run into a problem. The featured images are cropped. I looked at the code in post-thumbnail-template.php and it said:

function the_post_thumbnail( $size = 'post-thumbnail', $attr = '' ) {
    echo get_the_post_thumbnail( null, $size, $attr );
}

I thought that if I change the size from 'post-thumbnail' to 'full' problem would be solved but it wasn't.

So how can I add a image size that shows the image in full resolution. Do you see any errors in the code?

We have added theme support for post-thumbnails in a file (theme-init.php) that's linked to functions.php. In the same files I found this code (I didn't find any add_action add_action() for these, but when I removed them, our logo disappeared.

add_image_size('logo', 0, 45, false);
add_image_size('icon', 0, 51, false);
add_image_size('partner-logo', 150, 0, false);
add_image_size('long-img', 1920, 1200, false);
add_image_size('big-post', 1200, 1200, array('center', 'center'));
add_image_size('small-post', 1200, 1200, array('center', 'center'));
add_image_size('block-inf-img', 1200, 800, array('center', 'center'));
add_image_size('student-img', 1140, 480, array('center', 'center'));
add_image_size('big-post-th', 1200, 1200, array('center', 'center'));
add_image_size('rel-post-th', 1200, 1200, array('center', 'center'));
add_image_size('student-logo', 190, 0, false);
add_image_size('user_photo', 116, 116, array('center', 'center'));

Upvotes: 0

Views: 4558

Answers (2)

Snuffy
Snuffy

Reputation: 2096

To use your registered image size

the_post_thumbnail('image-size');

To use the original size of an image you dont need to register image size.

the_post_thumbnail('full');

Wordpress provides predefined image sizes such as: full,thumbnail,medium,medium_large,large,1536x1536,2048x2048 .Those are the image sizes for Wordpress 5+ version for older version may varay. You can check how to see all image size following this link with examples - Link

Upvotes: 1

dmgig
dmgig

Reputation: 4568

I think you need to add another to your list like:

add_image_size('full-size', 0, 0, false);

If I recall, if you use 0, 0 it treats that as no change to the scale (I could be wrong though). false for the third param tells it not to do any cropping.

And then use:

the_post_thumbnail('full-size');

As this is a WordPress specific question I would also point you to: https://wordpress.stackexchange.com/

Upvotes: 0

Related Questions