Croping not working
Hello guys! I'm using twill 3 for a personal project. I'm facing some issues with croping functionality, I'm using default glide for croping (I did not configured nothing in this direction, not sure if the problem is here) and all my image url's contains the attributes for height and width. The problem is that the image is rendered originally, not croped how I was expected, for example the attached image where the rendered one is not 200x200 px. In admin the media preview works fine, the image is croped. What I'm doing wrong? Thank you for this amazin cms!
13 Replies
Hello.
Can you show us how you render the picture (code)?
Do you specify crop name as a second param?
Hello, @kallefrombosnia, thank you for reply! Sure
And your uploaded picture size is?
Btw you can controll the w&h by setting params
Also you can check if media exists by
669x200 also the croped image in preview looks fine
thanks for the point, I also tried with fixed width and height but still not working, I'm not sure how this functionality should work, I have changed the parameters into image get url (ex: host/img/f9877556-5ce8-4a01-8b1f-aa7a40fbaaf9/black-friday-super-sale-realistic-black-gifts-boxes-with-golden-bows-dark-background-with-present-boxes-and-golden-percent-symbols-horizontal-banner-poster-header-website-illustration-vector.jpg?fm=jpg&q=80&fit=max&crop=200%2C200%2C297%2C0) and the image it's not croped. The image should be already croped when I access the url directly, no? Also I have added a die into index.php of laravel project and the image request is not going there, the image is accesed directly and rendered from assets folder, pb that's why the image is not croped
I took a look into glide documentation and there you have to define assets route in order to be accesed from laravel project and croped by glide plugin. While using glide & twillcms, do I have to define assets route?
that's how it looks with fixed width & height
Picture is already cropped from what I can see from your URL.
https://glide.thephpleague.com/2.0/api/crop/
<img src="kayaks.jpg?crop=100,100,915,155">
If you see docs for the crop, your example is cropped like 200,200,297,0Crop - Glide
Wonderfully easy on-demand image manipulation library with an HTTP based API.
Based on the url yes it should be cropped, but check out the result, it's not 200x200, the rendered image is the one from my picture
hello, anybody any idea about how can make the crop works? 😦 @ifox
wish you a wonderfull week guys
Hi @iAlexandru93 glide is already fully setup for you in twill and any request to the /img path (unless you've changed it in configuration) should go through the glide controller and apply the query parameters.
Try adding a single parameter to the url to see if the returned image is different than the original.
Make sure you haven't defined a route on the /img path.
Hello, @ifox! Thanks for your reply! It looks like the original image is rendered even if I add any parameter to the url. I added a die in index.php main project file and the die is not executable from image path, so it looks like the image is not rendered via Laravel project, it's rendered directly from assets path.
I do not have any route that can overwrite default image path
Well, finally I have figured out where the problem was. Thanks for debug! In my case the problem comes out from nginx, I'm using a default nginx config file for docker which was forwarding all .img/png/etc requests to files directly, I just added
location /img/ {
try_files $uri $uri/ /index.php?$query_string;
}
and everything works now! thank you guys!
Ha makes sense, great!