This isn’t a question exactly, more an observation and what I might do about it.
I use a function in a controller that pulls the value of an ‘articleimage’ field and either resizes it or crops it via the focus crop plugin.
However I just used it and specified dimensions that are identical to the source image. The quirk is this - it generated a thumbnail! I was expecting it to realise the dimensions where identical to the source image and spit out the URL to the source rather then resizing it. I know kirby is clever, perhaps I assume to much
Whats the simplest way to check the source images dimensions and only resize or focus crop if they are not exactly equal? I do feel like the resize function should handle this on its own though, since its a wasted process.
The thumb function does in fact check if the thumb is obsolete. This is the isObsolete function:
public function isObsolete() {
if($this->options['overwrite'] === true) return false;
// try to use the original if resizing is not necessary
if($this->options['width'] >= $this->source->width() &&
$this->options['height'] >= $this->source->height() &&
$this->options['crop'] == false &&
$this->options['blur'] == false &&
$this->options['upscale'] == false) return true;
return false;
}
So if the height is not set, the condition is not true and the thumb is created. While this probably doesn’t happen very often, I still consider this behavior improvable and created an issue on GitHub:
Smashing, thanks @texnixe - appreciate my use case was a fluke, normally i would use larger images and actually want to resize but i just hit this during development by (un)luck with images that happened to be the right size in the first place.