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've asked a similar question before: How to create thumbnails with a fixed width, so all of them will have the same width?

But... this one is related, but different. Please bear with me.

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.

Tnx!

share|improve this question
    
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 '11 at 18:28

2 Answers 2

up vote 2 down vote accepted

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

share|improve this answer
    
Many thanks for you thorough explanation Chris_O :) –  grrrbytes Apr 7 '11 at 9:56

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 ); 
share|improve this answer
    
I believe if you set one dimension to 0 it also won't be used. –  Jan Fabry Apr 5 '11 at 15:35
    
Ya I was wondering about that. –  Wyck Apr 5 '11 at 18:07

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.