Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

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