How to make images fit on homepage and product page?

Topic summary

A Shopify store owner needs help making product images fit properly in their display boxes on both the homepage and product pages.

Initial Solutions Offered:

  • One responder suggested adding CSS code (object-fit: contain) to the custom CSS box in the theme customizer
  • Another recommended adjusting the image ratio setting to “Adapt to image” in the Featured Collection settings under Online Store > Customize

Homepage Issue Resolved:
The “Adapt to image” setting successfully fixed the homepage display.

Product Page Mobile Issue:
Images still appear cropped on mobile view for the product page. The final solution provided involves adding specific CSS code targeting mobile screens (max-width: 749px) to adjust the .product__modal-opener height property.

Implementation:
The CSS should be added either to theme.css/base.css files or through the Custom CSS section in theme settings.

The discussion remains open pending confirmation that the mobile product page fix works.

Summarized with AI on October 26. AI used: claude-sonnet-4-5-20250929.

Hello all,

I want to make images of products fit the box on homepage and product page.

Store URL: https://u7yeji-na.myshopify.com

@Mamdouh_USD , hey, thanks for posting here.
Please add this CSS in the custom CSS box in the customizer.

.card__media .media img {
    object-fit: contain;
    background: #fff;
}

Hi @Mamdouh_USD ,

To adjust the image, go to Online store >> Customize >> click on Featured collection or collection and change the image ratio to Adapt to image which will automatically display whole image according to width.

If you stuck somewhere, feel free to message me or reply here. All the collections settings are same for both the home page and collection page.

Hi @AiTrillion ,

It worked perfectly on homepage but not on prdocut page. Can you help?

@Mamdouh_USD Basically, on the product page, the image doesn’t get cropped. The image is perfectly appearing. Can you please share the screenshot?

On mobile view, the image gets cropped. You can check it.

@Mamdouh_USD Please add the below code at Online store >> Edit code >> add to theme.css or base.css or go to Online store >> Customize >> Settings >> Custom CSS and paste the below CSS.

@media screen and (max-width: 749px) {
.product__modal-opener {
height: 100%;
}
}