Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

WordPress

How can I resize portrait & landscape images for use with ecommerce (Wordpress/PHP)

Hi there,

I am designing an Ecommerce site in Wordpress for an antiques store. My client has supplied me 50 or so high quality JPG images, of around 3 - 4 MB each. The issue is - some of the images are portrait (2848 x 4135 px), and some of them are landscape (4272 x 2848px). I have inserted the images into the site as they are, but as they are of different dimensions, they take up different amounts of space and my client is upset because the text and the buttons below the images do not line up.

There are also a few image centering issues also.

An example page is at: http://somers.young1.org/?product_cat=doulton-lambeth

I am using the Canvas theme from Woothemes together with WooCommerce.

Any of you bright guys know of a solution to this problem? It has been bugging me for rather a while.

Regards,

Robert :) London, Uk

4 Answers

There are plugins that you can use. But my actual recommendation is to start up photoshop or gimp and crop the pictures manually. Then sit down with your client and show him what dimensions he should use and how to crop and scale images. Just show him how to manage his stuff:

Here's the image info from the product page: 266px × 400px (scaled to 461px × 693px). That's not exactly great, scaling down is usually fine, scaling up sucks.

EDIT: Oops, duplicate comment

Matt Campbell
Matt Campbell
9,767 Points

Really, the issue is further back in the process then changing shape at the website.

For a site of mine, I make sure all images are 1920 x 1080 to start off with. That way, I know the styling will remain consistent across the site.

He either needs to supply all 50 images with the same dimensions or, be happy that the text in places isn't going to line up the same for all the pages with these images.

Andre Novak
Andre Novak
10,751 Points

What do you think about using "div.productImage {background-size: contain}" and putting images inside the "<div class="productImage"></div>? https://developer.mozilla.org/en-US/docs/Web/CSS/background-size