vendredi 26 décembre 2014

How to scale up image into thumbnail without distorting it?


I have a section in my single post page that contains the post thumbnail. When using a smaller image as featured image (smaller than the thumbnail size, in width or height) it gets distorted to fill the thumbnail and lose its proportion. When the featured image is bigger than the thumbnail size or at least has a similar proportion, it seems to work just fine.


An image showing the case: http://i.imgur.com/bUd2INA.jpg


Here's all the code I used:



add_image_size( 'thumbpost', 698, 320, true );

<div class="thumbpost"><?php { the_post_thumbnail('thumbpost' ); } ?></div>

.thumbpost{
width:100%;
height:320px;
overflow:hidden;
}

.thumbpost img{
width:100%;
height:100%;
}


And seeing the image that Wordpress has generated, it generates a proportional image but still smaller than the thumbnail size, so I wonder if there's something missing on the code?





Aucun commentaire:

Enregistrer un commentaire