Shopify

Mastering Your Shopify Product Gallery: Advanced Tips for Hiding and Reordering Images

Custom CSS code for hiding Shopify product image
Custom CSS code for hiding Shopify product image

Mastering Your Shopify Product Gallery: Advanced Tips for Hiding and Reordering Images

Hey there, fellow store owners! Ever found yourself wanting to tweak something just a little on your Shopify store, only to discover it’s not quite as straightforward as clicking a button? You’re not alone! At Shopping Cart Mover, we specialize in helping merchants optimize their stores, and sometimes, the smallest adjustments can make the biggest difference. We recently dove into a fascinating discussion on the Shopify community forums that really highlighted this.

The topic? A store owner, JustinasR, simply wanted to know: "How do I hide the first main product image in the product photo gallery?"

It sounds simple, right? But as the thread unfolded, it became a great example of how different themes and approaches can lead to different solutions. Let's break down what the community experts shared and how you can apply these insights to your own store.

Why Would You Want to Hide the First Image?

Before we jump into the 'how,' it's worth considering the 'why.' As experts in e-commerce migrations and development, we understand that visual presentation is paramount. The 'first' image isn't just for your product page gallery; it's often what Shopify uses for crucial elements across your store and beyond:

  • Collection Pages: It's typically the thumbnail representing your product.
  • Cart and Checkout Pages: The image accompanying the item in the customer's cart.
  • Social Media Previews: What appears when your product link is shared on platforms like Facebook or Twitter.
  • Search Engine Results: The image displayed in Google Shopping or organic search snippets.
  • Email Marketing: Often the default image for product recommendations.

So, wanting to hide it *only* on the product page, but perhaps keep it for other uses, adds a layer of complexity. Or maybe you have a specific hero image for the product page that you don't want to appear in the scrollable gallery, or a variant-specific image that shouldn't be the initial default. Whatever your reason, the community had some excellent solutions, ranging from simple administrative tweaks to more advanced custom CSS.

Solution 1: The Simplest Approach (No Code Needed!)

Sometimes, the easiest fix is the best. If the image just shouldn't be first, or shouldn't be there at all, these administrative options are your first stop. They are clean, theme-agnostic, and update across all Shopify touchpoints.

Option A: Reorder Your Product Media

If the image is perfectly fine, but just not suitable for the first spot in the gallery, you can simply change its position. This is a super clean fix because it updates everywhere Shopify uses that 'first image' – collections, social shares, and more.

  1. From your Shopify admin, go to Products.
  2. Click on the product you wish to edit.
  3. Scroll down to the Media section.
  4. Click and drag the images to reorder them. The image at the top will be considered the 'first' image.
  5. Click Save.

Option B: Remove the Image Entirely

If the image is simply not needed anywhere, the most straightforward solution is to remove it. This ensures it won't appear on any product galleries, collection pages, or social shares.

  1. From your Shopify admin, go to Products.
  2. Click on the product you wish to edit.
  3. Scroll down to the Media section.
  4. Hover over the image you want to remove and click the trash can icon.
  5. Click Save.

Solution 2: Custom CSS for Targeted Hiding

What if you need the image to exist (e.g., for specific variant selections or other backend logic) but simply don't want it visible in the main product gallery? This is where custom CSS comes into play. It allows for precise control over your store's visual presentation without altering the underlying HTML structure.

The Initial Attempt: Simple `display: none`

An early suggestion in the forum, by Sam_Expertise001, involved adding a simple CSS snippet:

.product__media-list .media:first-child {
  display: none !important;
}

This code aims to hide the very first media item in the product gallery list. While effective for some themes, JustinasR quickly discovered a common pitfall: it might leave an empty space or, worse, hide the entire gallery if the selectors aren't precise enough for the specific theme in use. This highlights a crucial point: Shopify themes vary significantly. What works for Dawn might not work for Impulse, and vice-versa.

The Refined Solution: Ploqo's Robust CSS

Ploqo's contribution to the thread provided a much more robust and theme-agnostic solution, specifically tested on multiple themes and devices. This code doesn't just hide the image; it also ensures that the *second* image takes its place visually, preventing an empty gap.

Understanding Ploqo's Code:

[data-product-gallery-navigation-layout="featured"] {
  position: relative !important;
}
[data-product-gallery-figure="0"] {
  display: block !important;
  position: absolute !important;
  top: 0;
  left: 0;
  width: 100% !important;
  opacity: 0 !important;
  pointer-events: none !important;
}
[data-product-gallery-thumbnail="0"] {
  display: none !important;
}
  • [data-product-gallery-navigation-layout="featured"]: This targets the main container of the product gallery, ensuring its positioning context is correct for absolute positioning.
  • [data-product-gallery-figure="0"]: This is the key. It targets the *main display area* for the first product image (index 0). Instead of just `display: none`, it makes the image completely transparent (`opacity: 0`), positions it absolutely (so it doesn't take up space), and disables pointer events (so it can't be clicked). This clever approach allows the subsequent image to visually appear as the 'first' without an empty void.
  • [data-product-gallery-thumbnail="0"]: This specifically hides the *thumbnail* of the first image in the gallery navigation strip, ensuring it doesn't appear as a selectable option.

Steps to Implement Ploqo's Custom CSS:

  1. From your Shopify admin, go to Online Store > Themes.
  2. Find your current theme, click the three dots (...), and select Edit code. (Alternatively, for many modern themes, you can go to Customize > Theme settings (gear icon) > Custom CSS).
  3. In the theme editor, navigate to the Assets folder and open a file like theme.css, base.css, or custom.css. If using the Custom CSS section in Theme Settings, simply paste it there.
  4. Paste the provided CSS code snippet at the very bottom of the file or in the Custom CSS section.
  5. Click Save.
  6. Always test thoroughly on various products and devices (desktop, mobile) to ensure the desired effect and no unintended side effects.

Important Note: If you're unsure about editing theme code, always duplicate your theme first. This creates a backup you can revert to if anything goes wrong.

When to Seek Expert Help

While custom CSS can be a powerful tool for fine-tuning your Shopify store's appearance, it requires a basic understanding of web development. If the provided solutions don't work for your specific theme, or if you encounter unexpected issues, it's a sign that your theme's structure might be different, requiring a more tailored approach.

For complex customizations, theme-specific challenges, or when you're migrating your store to Shopify and need a seamless transition, don't hesitate to reach out to professionals. At Shopping Cart Mover, we specialize in ensuring your e-commerce platform, whether you're starting a new Shopify store or moving an existing one, is perfectly optimized for your business needs.

Conclusion

Hiding or reordering your first product image in Shopify might seem like a small detail, but it can significantly impact user experience and product presentation. By understanding both the no-code administrative options and the power of custom CSS, you gain greater control over your store's aesthetic. Remember to always test your changes and, when in doubt, consult with a Shopify development expert to ensure a smooth and effective customization.

Share:

Use cases

Explore use cases

Agencies, store owners, enterprise — find the migration path that fits.

Explore use cases