How to auto-fit photos on product page without cropping?

Topic summary

A Shopify store owner is experiencing image cropping issues across multiple pages (product pages, homepage, and collection pages). Photos are being cropped instead of auto-fitting to display properly in portrait orientation.

Solutions Provided:

  • Product grid images: Added CSS code to component-card.css using object-fit: contain to prevent cropping
  • Homepage images: Modified component-card.css with .card__inner { height: 100%; } to fix display issues
  • Image proportions: Adjusted aspect ratios in base.css using custom padding-bottom values and global-media-settings selectors to make oversized images (like “yoga frog”) more proportional
  • Product page images: Applied similar padding adjustments to control image sizing on individual product pages

All CSS modifications were added to the bottom of their respective files in the theme’s code editor. The user encountered a minor syntax error (missing closing brace) during implementation but successfully resolved all issues with the provided code snippets. The discussion reached full resolution with all image display problems fixed.

Summarized with AI on November 23. AI used: claude-sonnet-4-5-20250929.

A number of my photos are cropped on the product page. Is there some sort of code to have it auto-fit in a portrait size without being cropped? I tried the code recommended here, but it distorted the image.

Thanks in advance!

Hi @aelitzer

Could you share your url store and password? I will help to check it.

there’s not a ton more to see besides the screenshot but it’s https://1ca775.myshopify.com/.

password is labelshopper

Hi,

May I suggest to update code these steps:

  1. Go to Store Online-> theme → edit code
  2. Assets/component-card.css
  3. Add code below to bottom of file
body .card__media .media img {
	object-fit: contain;
}
2 Likes

Yes, this did the trick. thank you so much!!

@EBOOST I’m running into the same issue on my home page now. Is there something similar I can add to my homepage to have the same effect? Thank you!

Hi @aelitzer

May I suggest to update code these steps:

  1. Go to Store Online-> theme → edit code
  2. Assets/component-card.css
  3. Add code below to bottom of file
.card__inner { height: 100%;}

Yes! That did it!

One follow-up question - is there a way to make an image like the “yoga frog” shorter and more proportional to the other photos? It is also quite large on the product page as well?

Really appreciate your help!!

Hi @aelitzer

May I suggest to update code these steps:

  1. Go to Store Online-> theme → edit code
  2. Assets/base.css
  3. Add code below to bottom of file
.card__inner.ratio::before {
  padding-bottom: 100%;
}
.global-media-settings[style="padding-top: 309.0909090909091%;"]{
    padding-bottom: 100%!important;
}
.global-media-settings[style="padding-top: 309.0909090909091%;"] img {
	object-fit: contain;
}

Unfortunately that one did not appear to change anything

Hi @aelitzer

your file is missing “}”. You can check the screenshot below

That’s great thank you!!

Less important, but is there any way to apply a similar code to the product page itself? The photo is quite large https://1ca775.myshopify.com/products/cast-iron-yoga-frog

Hi @aelitzer

Could you adjust like the screenshot?

.global-media-settings[style="padding-top: 309.0909090909091%;"]{
    padding-top: 100%!important;
}

That’s perfect - thank you!