TC
Twill CMS15mo ago
twan

How to load images in smaller size while keeping aspect ratio and not cutting parts of it off?

Hello, I am trying display images with a smaller width that I uploaded in my CMS but without any crop. So for example a logo that is 2000px by 3000px I want to display it with a width of 300px while keeping correct aspect ratio and without cutting parts of the image off. It's not really clear for me in the documentation how to do that. Currently I have this code: @foreach($logos->imageObjects('image', 'default') as $logo) <div class="swiper-slide d-flex"> <a href="{{ $logos->image('image', 'default', ['w' => 300, 'fit' => 'stretch'], false, false, $logo) }}" class="card-img d-flex align-items-center p-3" data-gtf-mfp="true" data-gallery-id="03"> <img src="{{ $logos->image('image', 'default', ['w' => 300, 'fit' => 'stretch'], false, false, $logo) }}" loading="lazy" alt="product gallery" class="w-100 h-auto"> </a> </div> @endforeach With this code the width is indeed 300 but parts of the image are cut off. Example: I'm just using twill out of the box, no extra installed image or media plugins.
No description
3 Replies
kallefrombosnia
kallefrombosnia15mo ago
Size - Glide
Wonderfully easy on-demand image manipulation library with an HTTP based API.
kallefrombosnia
kallefrombosnia15mo ago
You can test with other params other than stretch
twan
twanOP15mo ago
Thanks!
Want results from more Discord servers?
Add your server