openfoodfoundation / openfoodnetwork

Connect suppliers, distributors and consumers to trade local produce.
https://www.openfoodnetwork.org
GNU Affero General Public License v3.0
1.1k stars 716 forks source link

View list of products #12245

Closed kirstenalarsen closed 6 months ago

kirstenalarsen commented 6 months ago

The Product images are not scaling correctly / staying square - on most screen views they are distorted

Image

JbPasquier commented 6 months ago

Fixed.

Capture d’écran 2024-03-07 à 00 28 29

image

kirstenalarsen commented 6 months ago

Thanks @JbPasquier that's much better! Is there a way to have BOTH the ratio locked and the actual squaring of the image?

mariocarabotta commented 6 months ago

Thanks @JbPasquier that's much better! Is there a way to have BOTH the ratio locked and the actual squaring of the image?

I'm not suggesting this post is how it should be implemented, but by doing a quick search this is the kind of outcome for image cropping > https://jonathannicol.com/blog/2014/06/16/centre-crop-thumbnails-with-css/

I'll leave it up to you JB to decide which approrach would work best

JbPasquier commented 6 months ago

Is there a way to have BOTH the ratio locked and the actual squaring of the image?

I can try some tricks, but it would be a better practice to handle this beforehand, and ensure a correct ratio when a producer update its picture.

I'm not suggesting this post is how it should be implemented, but by doing a quick search this is the kind of outcome for image cropping > https://jonathannicol.com/blog/2014/06/16/centre-crop-thumbnails-with-css/

I just tried, does not work properly, because of the combination with the flex system I used for the mosaic,
The main issue is that those squares have a dynamic height/width based on the ratio of the picture.
In your link, they create a personalized class for portrait to address this issue, but here, I have no clue on the ratio of the image before it's on screen, and the logic approach of our framework is to avoid doing those manipulation on client side.

I'll try some other things and let you know. Let me know if you have any way to handle it sooner on the process.

JbPasquier commented 6 months ago

Done, I've moved the image to the background layer, using cover sizing to ensure the square ratio. I also added an intermediate media query for 3 columns to avoid too much distortion on card's text.

Capture d’écran 2024-03-07 à 12 21 06 Capture d’écran 2024-03-07 à 12 21 11 Capture d’écran 2024-03-07 à 12 21 15 Capture d’écran 2024-03-07 à 12 21 19

kirstenalarsen commented 6 months ago

I'm happy with this, thank you @JbPasquier . @mkllnk can you confirm you're ok with how this is done i.e. that we shouldn't be worrying about trying to do on our side first

mkllnk commented 6 months ago

Yes, great. That's exactly what we had in mind.