- Published on
Navigating the Image Maze How We Conquered Different Collection Image Sizes on Shopify
- Authors
- Name
- Entaice Braintrust
Navigating the Image Maze: How We Conquered Different Collection Image Sizes on Shopify
There we were, sipping our morning coffee, when the world of online commerce laid yet another challenge at our feet. It wasn't the first time, and goodness knows it won't be the last. But let's talk about that day when our images decided to play a game of hide and seek with proportions. We wanted them orderly, nicely framed, like a perfectly organized book shelf. But just like cats, they had a mind of their own—fancy that!
So, there we were, our friend Jessie facing a distinct dilemma on their Shopify webshop. They had multiple collections — much like a digital art gallery — two of them very fond of the portrait image size, while the third collection yearned for a different vibe, a stockier, boxier 4:3 ratio. Typing away at the speed of light, Jessie changed the theme settings, hoping for a miracle, only to find themselves performing a synchronized dimension dance across all images instead. Oh, the woes and wonders of web design!
Here's how we took a detour around the cookie-cutter approach.
The Image Riddle Begins
Shopify, in all its prowess, can sometimes feel like an old, cryptic castle with hidden doors. Jessie wanted those collections to beam with individuality. However, changing the theme settings, as you might have guessed, standardized everything. Every collection image became a clone, losing their unique spark.
Let's reminisce about when we decided to cook dinner for our favorite folks — one wanted pasta, another wanted salad, while someone threw a curveball requesting a spicy curry. The kitchen was chaos, but everyone's distinct tastes and preferences were honored quite proudly. Why not treat our beloved webshop collections with the same care and attention? After all, one size doesn’t fit all!
To achieve this bit of magic using Shopify, code and creativity were our best allies.
Setting Up Our Canvas: Liquid and CSS
Now, imagine yourself opening a blank canvas, paints and brushes at the ready. We need to tweak, fine-tune, and tailor. And guess what? We can use Shopify Liquid along with some cheeky CSS to orchestrate this masterpiece.
Step one, have a wee look at your theme's code. You can do this by going to your Shopify admin, clicking on Online Store, and then Themes. Beside your active theme, there's a little ellipsis dropdown — click Edit Code. It's showtime!
Liquid Logic
In your theme, locate the file responsible for displaying collection pages. It might be named something like collection.liquid
or collection-template.liquid
. If it feels like finding Waldo, don't worry. We've been down that road.
Within this file, we sprinkle a bit of Liquid logic to target the specific collection that screams for a tailor-made image size. For instance, should your third collection be titled Fancy Feathers
, use its handle to deftly apply the special 4:3 image ratio.
Here's a quick dip into code:
{% if collection.handle == 'fancy-feathers' %}
<!-- Custom image logic here -->
<img src="{{ collection.image.src | img_url: '600x450' }}" alt="{{ collection.title }}">
{% else %}
<!-- Default 2:3 logic here -->
<img src="{{ collection.image.src | img_url: '600x900' }}" alt="{{ collection.title }}">
{% endif %}
This snippet is our maestro, conducting the harmony of image sizes your collections deserve!
CSS Charm
Yet, images can be a tad unruly. Once Liquid gets them into shape, a dab of CSS makes them stylishly presentable. Fancy using CSS Grid or Flexbox to restrain their wild pixels? Or maybe just a simple max-width directive to polish them up.
Insert this CSS flourish in your theme's stylesheet, usually found at assets/theme.scss.liquid
:
.fancy-feathers-image {
width: 100%;
height: auto;
object-fit: cover;
}
.default-collection-image {
width: 100%;
height: auto;
object-fit: contain;
}
And before we forget, don't get lost in the aesthetics — remember to pair CSS with correct HTML classes in your Liquid files.
The Grand Finale: Publishing with a Flourish
If the code had a scent, it’d be a heady mix of pixels and perseverance, with just a hint of espresso! After saving your changes like an artist finally signing their painting, jump back to Shopify's cheerful backend and go to your chosen collection page. Give it a once-over (or twice) to ensure every image stands proud, holding their newfound shapes.
Together, through the sometimes tangled forest that is code and creativity, Jessie’s collections now present themselves with dapper flair. Each image sits happily “correct” in its designated ratio — like seats at a carefully curated dinner party. Individuality triumphs again!
And next time when those pesky pixels misbehave, remember that together, through the digital brushstrokes of Liquid, CSS, and a smidge of creativity, we can tame the image dilemma. Until our next adventure in the remarkable realm of Shopify, let’s keep sharing the trials and triumphs. Cheers!