Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm having trouble finding out how to accomplish this - I want to display a cropped version of an image in the post. So when it's uploaded, it would automatically be displayed cropped. Is there any way to do that? For example, this would be the original image uploaded and this is what it would look like in the post

Is there a way to set that cropping be default? It would be great if the user would upload the image already cropped, but if they don't, I want to have a fallback.

share|improve this question

3 Answers 3

up vote 0 down vote accepted

try this

  1. define a custom image size (add_image_size)

    add_image_size(name,w,h,true);

    where w and h for height and width of your image.and fourth parameter true for hard croping of image.read wordpress codex for that

  2. put your custom image size name in the_post_thumbnail function

    the_post_thumbnail('name')

or

if your design is not responsive then you can set image size using css.

--class/id-- img{
width:w;
height:h;
}
share|improve this answer
    
The site is responsive, but that first solution should work. Thanks!! I somehow overlooked that crop part –  tstrebeck Jun 5 '13 at 12:42

You can use custom image size as in above answer and use it with the the_post_thumbnail function. If you don't want to do this and want to apply the crop to all the featured images then there is a more simple solution than this.

In wordpress admin, goto

Settings->Media.

There you can set thumbnail size and there is also an option for cropping to exact dimension. Hope this helps.

share|improve this answer
<?php set_post_thumbnail_size( $width, $height, $crop ); ?>

This function allows you to register additional image sizes for Featured Images, set $crop parameter to true

See codex

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.