I’m using a very basic ‘files’ field in the panel to add images and loop through them to create a lightbox gallery (currently using the ‘Lity’ jquery plugin).
It works fine but I’m wondering what the benefits of using kirby’s built in thumbs functionality is for something like this and indeed it’s best usage scenerios outside of this?
In this rough example code I’m calling 2 versions of the uploaded image; one cropped and one original. I can’t really work out why it’s better to have kirby generate the thumb if I can do it this way; or is the method there so you can globally control thumb parameters?
Thanks for the reply; what I’m having trouble understanding is what is the difference between requesting a thumb and just requesting a version of the image in the same specified spec?
So for example, if i defined a crop of 300 in my config for thumbs, what would be the difference between $image->thumb and $image->crop(300) ?
Thanks for your patience, just trying to learn as I go!
I guess you are talking about thumb presets? The thumb() method has a lot of different options (width, height, blur, bw, crop etc.) , while crop() is a thumb shortcut for cropping, similar to resize(), bw() etc. Maybe I don’t quite understand the question.
So in your first response you said the main use case was to reduce the file size of the image, for example cropping it. But I can do that with the crop and size filters for images, so im not sure what the difference between doing that or using the thumbs feature is.
The missing piece of the puzzle is probably this: A cropped image is also a thumb, just like an image manipulated with the bw() method is also a thumb. So the end result is just the same no matter if you call thumb() or crop(), but crop() is a shortcut if you only need cropping.
Would like to use a global thumb-quality for cropped images.
Just found out, the crop-method can’t use the configured quality by default. is that true?
(but it takes the default format)
Any recommendation, which crop-method works better for that case?
Thx @texnixe , works now (in K3.7.5)
But to see the difference on change global quality setting, we have to delete the media-folder first.
I guess that is, because global quality settings are not being added to the filename, isn’t it?
Yes, the crop function doesn’t automatically apply those default settings, you have to pass that option explicitly, see the source code, the default setting for quality is null.
You could create a custom crop method that does this by default.