0

I've asked a similar question before. This one is related, but different.

Right now: if you insert an image in a post as a thumbnail by the media-library, you can choose between 4 different sizes: thumbnail, medium, big and actual size. This is fine. However: the dimensions of the thumbnail are determined by whether the image is landscape or portrait. You can set a maximum width or height in your media-settings. Maximum 300 width and maximum 300 height, for instance, will make a landscape image 300px width and a portrait image 300px height. So it won't be always 300px wide. Only if it's a landscape image.

Please correct me, if I'm mistaken, but this is what I've encountered so far.

The point: my client used to work with movable type, but decided to switch to wp. In mt, however, you could set a maximum width of a thumbnail, so that a thumbnail would be always this width, regardless of it being portrait or landscape. He wanted to have all of his thumbnails the same width, regardless of its orientation.

This is not compatible with the way wp works, since the width will depend on the image's orientation.

Question: how to make wp work like my client wants (ie: to set all the thumbnails the same width, whether landscape or portrait)

And yes, the question is very similar to the one I referred to in the beginning, but that one was concerned with post-thumbnails which would be always the same size and this fixed width could be set within templates. In this case this is different: images are inserted in posts and the media-library determines the size.

Not sure if I made myself clear. If I have: anyone has a solution? Be it a plugin (haven't found one yet) or a hack. If I haven't: shoot me and I'll try to clarify.

1
  • Did you know that you can click the checkmark to accept an answer if it solved your problem? It will give a reputation increase to the person who wrote it and to you, and the question will no longer stay "unanswered". Currently you have not accepted any answer, which can give people the impression you won't "reward" their efforts, making them skip your questions.
    – Jan Fabry
    Apr 5, 2011 at 18:28

2 Answers 2

2

You can set a maximum width for all image sizes and WordPress will crop portrait and landscape oriented images to that same width.

In your media settings set the width field and leave the height field blank.

enter image description here

When you upload a landscape oriented image the size will never go past the max width of 300px and the height will be proportionate .

enter image description here

.

When you upload a portrait orientated image the max width will still be 300px.

enter image description here

.

When the post or page is displayed both images will line up and be the same width:

enter image description here

1
  • Many thanks for you thorough explanation Chris_O :)
    – grrrbytes
    Apr 7, 2011 at 9:56
3

You already asked this question but here are some solutions.

Use hard-coded CSS for the width.
Use TimThumb

Use a trick and set the height to a huge number like 9999, that way the height will never be used.

set_post_thumbnail_size( 300, 9999 ); 

Or use hard-cropping by setting the parameter to true.

set_post_thumbnail_size( 300, 300, true ); 
2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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