Aayush
Aayush

Reputation: 3098

WordPress Post Thumbnail Problem

I have two types of posts in the theme I am creating Trending and Normal. Post thumbnail image size is: 300x169 and I show it as that size when a trending post is displayed. But when this post is not trending I want the thumbnail size to be: 145x80. I tried the_post_thumbnail( array(145,80) ); but it doesn't work. Instead this crops the image in squarish dimensions. I don't want it to crop but decrease in size via HTML.

Can anyone please help me with this.

Thanks! Appreciate all the help.

Upvotes: 3

Views: 900

Answers (2)

Alex
Alex

Reputation: 4774

You can change the size from CSS by doing this:

<div style="width:145px;height:80px;"><?php the_post_thumbnail();?></div>

Upvotes: 0

Ben
Ben

Reputation: 1535

You could try adding a new image size and then when you call the_post_thumbnail you pass it the name of the new image size you have set. Set the hardcrop flag to false if you don't wan't the image resizing via hard crop.

http://codex.wordpress.org/Function_Reference/add_image_size

Upvotes: 4

Related Questions