Jump to content

Changing the aspect ratios for products on mobile

Go to solution Solved by tuanphan,

Recommended Posts

Hello, I am a photographer looking to solve a seemingly simple problem. My photos don't all share the same dimensions. I want to sell prints online and built out the Squarespace store however, on mobile when someone clicks on the product, they are shown the product in a square format (or any other pre-selected aspect ratio) when I want them to be able to see the entire photo as uploaded on the desktop version. Apparently, there is no option for this so I need to turn to code but have little experience in that. 

Please help! 

Link to comment
  • Replies 12
  • Views 1.9k
  • Created
  • Last Reply

Top Posters In This Topic

  • Solution
15 hours ago, Tyrus said:

Sure here it is! Keep in mind it's on Mobile 

https://www.tyrusxanthosphoto.com/prints

You can add this to Design > Custom CSS

@media screen and (max-width:767px) {
.ProductItem-gallery-slides-item img {
    object-fit: contain !important;
}
}

 

Email me if you have need any help (free, of course.). Answer within 24 hours. 
Or send to forum message

Contact Customer Care - Learn CSS - Buy me a coffee (thank you!)

Link to comment

Thank you so much! That worked! Follow up question. I have the code in there for the issue above. Now how do I make the main product page have 2 rows instead of just one item at a time? I had it, but then somehow I lost the 2 collumns 

Link to comment

I tried to fix it myself using chat GPT and google. I came up with this code so far: 

 

@media only screen and (max-width: 767px) {
  .products .list-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
  }

  .products .grid-item {
    width: 48%;
  }

  .ProductItem-gallery-slides-item img {
    object-fit: contain !important;
  }
}


It achieved everything I am looking for on mobile but now when I click into a product on my desktop version, the photo is a square and not its original shape. Almost there! 

Link to comment

I finally got it with this code. 

 

/* For mobile screens */
@media only screen and (max-width: 767px) {
  .products .list-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
  }

  .products .grid-item {
    width: 48%;
  }

  .ProductItem-gallery-slides-item img {
    object-fit: contain !important;
  }
}

/* For desktop screens */
@media only screen and (min-width: 768px) {
  .ProductItem-gallery-slides-item img {
    object-fit: contain !important;
    max-width: 100% !important;
    max-height: none !important;
  }
}


Please let me know if you think this is good or can be improved! 

Link to comment
6 hours ago, EnigmaFlame2311 said:

Hi!

I'm having the same issues! **On mobile**
and I can't get any of the above codes to work.. Help!?

https://octopus-pumpkin-nn9x.squarespace.com/config/

Screenshot 2023-07-06 at 5.08.42 PM.png

Screenshot 2023-07-06 at 5.08.51 PM.png

The site is private. We can't access it.

Can you follow this to share url?

 

Email me if you have need any help (free, of course.). Answer within 24 hours. 
Or send to forum message

Contact Customer Care - Learn CSS - Buy me a coffee (thank you!)

Link to comment
  • 6 months later...
On 1/29/2024 at 8:22 AM, emiehughes said:

hello! I am having this same issue on mobile as well - @tuanphan would you be able to help me with code for this issue? Specifically on the individual product pages, like this one?

https://www.annguideramatey.com/ireland/p/emeraldsandsaphires

 

I see you solved with this code?

@media only screen and (min-width: 768px) {
    .ProductItem-gallery-slides-item img {
        object-fit:contain !important;
        max-width: 100% !important;
        max-height: none !important
    }
}

 

Email me if you have need any help (free, of course.). Answer within 24 hours. 
Or send to forum message

Contact Customer Care - Learn CSS - Buy me a coffee (thank you!)

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment


×
×
  • Create New...

Squarespace Webinars

Free online sessions where you’ll learn the basics and refine your Squarespace skills.

Hire a Designer

Stand out online with the help of an experienced designer or developer.