Fixing the Awkward: How to Align Single Product Images Perfectly on Shopify
Hey there, fellow store owners! Ever found yourself staring at a product page, scratching your head because one of your product images just looks... off? It’s a surprisingly common head-scratcher, especially when you have products with just a single photo. You want everything to look consistent, clean, and professional, but sometimes those solo shots decide to play by their own rules, leaving an awkward gap or weird alignment.
Someone in the Shopify community, Tilda_Falth, recently ran into this exact issue, and it sparked a great discussion we can all learn from. Tilda was seeing something peculiar: her products with multiple images displayed perfectly, with the image neatly aligned at the top, right alongside the product title. Take a look at what she shared:

But then, for products with only a single image, things went wonky. Instead of starting at the top, the image was stubbornly centered in its block, creating an unsightly gap above it. Tilda summed it up perfectly: “it looks super off since I want all my product images to start at the same height as the title.” Here’s what she was seeing with the single image:

This is a classic case of CSS styling getting a bit overzealous. As our resident coding wizard, tim_1, explained, the main culprit is often a parent element (the container holding your image) that's set to a specific aspect ratio – often a square – making it taller than your actual image. When your image is then limited in size (Tilda had her images capped at 470px max-width and max-height), the browser vertically centers that smaller image inside the oversized parent. Voila! Awkward empty space.
Unpacking the Community Solutions
The beauty of the Shopify community is how quickly folks jump in to help. We saw a few different angles emerge, and combining them gives us a powerful solution.
Solution 1: Resetting the Aspect Ratio
Tim_1’s primary suggestion targeted the underlying aspect-ratio issue. By telling the .slideshow--single-media slideshow-slide element (which often wraps your product media) to unset its aspect ratio, you allow it to naturally conform to the size of its content – your image. This can often resolve the extra height problem right away.
.slideshow--single-media slideshow-slide {
aspect-ratio: unset !important;
}
Tim_1 even shared a neat before/after showing how this simple line of CSS can make a huge difference:
→ 
Solution 2: Aligning to the Top
Another helpful expert, devcoders, chimed in with a slightly different angle that focuses on explicitly telling the image to align to the top of its container. This uses flexbox properties, which are incredibly powerful for layout control. By setting align-items: flex-start, you ensure the image sticks to the top, fulfilling Tilda’s desire for it to align with the title.
.product-media-container.constrain-height:has(.product-media-constraint-wrapper) {
display: flex;
justify-content: center;
align-items: flex-start !important;
}
Devcoders provided a visual example of how this can look once implemented:

Tim_1 also mentioned this approach, noting it could leave empty space below the image if the container is still too tall. This is why combining solutions often makes the most sense.
Solution 3: Adjusting Image Max-Width/Height
Finally, Laza_Binaery brought up a good point about Tilda’s existing code that limited her product images to 470px. While this isn't directly about alignment, it impacts how much space the image occupies. If the goal is a larger image or if the 470px limit was inadvertently contributing to the centering issue by making the image too small for its container, then adjusting these limits is important. Laza suggested overriding them with larger values, like 1200px:
.product-media-gallery__slideshow--single-media .product-media-constraint-wrapper {
max-width: 1200px !important;
}
.product-media-gallery__slideshow--single-media .product-media {
max-width: 1200px !important;
max-height: 1200px !important;
}
Tilda’s original code for comparison:
/*Tilda kod för mindre product image*/
.product-media-gallery__slideshow--single-media .product-media-constraint-wrapper {
max-width: 470px;
margin: 0 auto;
}
.product-media-gallery__slideshow--single-media .product-media {
max-width: 470px;
max-height: 470px;
}
This part is more about your desired image size, but it's good to be aware of how your max-width and max-height settings interact with the aspect ratio and alignment.
Putting It All Together: Your Step-by-Step Fix
Based on the community's wisdom, here’s a robust way to ensure your single product images behave beautifully and align perfectly with your product titles. Remember to always back up your theme before making code changes!
Step 1: Tackle the Aspect Ratio
This is often the core issue. By unsetting the aspect-ratio, you give the image container the flexibility to size itself according to the image, rather than a fixed, potentially taller, ratio.
- From your Shopify Admin, navigate to Online Store > Themes.
- Find your current theme, click Actions > Edit code.
- Look for your main CSS file. This is often named
base.css,theme.css,styles.css, or similar, usually found under the Assets folder. - At the very bottom of this file, add the following CSS snippet:
/* Fix for single product image aspect ratio */ .slideshow--single-media slideshow-slide { aspect-ratio: unset !important; } - Save your changes.
Step 2: Ensure Top Alignment
Even after resetting the aspect ratio, some themes or other CSS might still try to center things. This step explicitly tells the image to start at the top.
- If you're still in the code editor from Step 1, you can add this right after the previous code. Otherwise, navigate back to Online Store > Themes > Actions > Edit code.
- In the same CSS file (e.g.,
styles.css), add this snippet below the previous one:/* Ensure single product image aligns to the top */ .product-media-container.constrain-height:has(.product-media-constraint-wrapper) { display: flex; justify-content: center; align-items: flex-start !important; } - Save your changes.
Step 3: Review Your Image Size Limits (Optional but Recommended)
If your images still appear smaller than you'd like, or if you suspect your existing max-width was part of the problem, consider adjusting it. Tilda had a 470px limit, and Laza_Binaery suggested increasing it. You might have similar code in your theme. If you want larger images, you can override or modify these values. You might find this code in the same CSS file, or sometimes directly in the theme customizer's 'Custom CSS' section for the product page.
- Go to Online Store > Themes > Customize.
- Navigate to a product page that has a single image.
- On the left sidebar, click on the Product Information section.
- Look for a section titled Custom CSS (or similar).
- If you have existing code limiting your product image size, you can modify it, or add new code to override it, like Laza_Binaery suggested:
/* Override default single product image size (adjust as needed) */ .product-media-gallery__slideshow--single-media .product-media-constraint-wrapper { max-width: 1200px !important; /* Adjust to your desired max width */ } .product-media-gallery__slideshow--single-media .product-media { max-width: 1200px !important; /* Adjust to your desired max width */ max-height: 1200px !important; /* Adjust to your desired max height */ } - Save your changes.
After applying these changes, check your product pages thoroughly, especially those with a single image. You should see a much more consistent and professional look, with your images aligning nicely at the top, just like Tilda wanted! It just goes to show how a little CSS tweak, combined with some community insights, can make a big difference in your store's presentation. Happy selling!