getkirby-v2/toolkit

Thumb method creates thumb on resize even if image is same width

Closed this issue · 3 comments

Let's say my image is 800 x 600 and I put the following code into my template:

$page->image()->resize(800)

=> Kirby creates a thumb.

If instead I use:

$page->image()->resize(800, 600)

no thumb is created, although the result of the first resize is an image of size 800 x 600, i.e. thumb creation is obsolete but the isObsolete() function doesn't respect this.

See https://forum.getkirby.com/t/image-resize-quirk/9541/5

Just to make sure I understand the issue correctly:

In your opinion the bug is that the first call (without an explicit height) creates a thumb even though it wouldn't need to as the original image is already 800 x 600? The behavior of calling the method with an explicit height (second example) then is as expected, right?

Yes, exactly, the isObsolete() method only returns true if both width and height are given and if both are the same as the original image's width and height. If only the width (or the height?) is given, the isObsolete() method will never return true. These cases might be edge cases and not necessarily justify making this method more complicated than necessary, but the issue came up in the forum, so I added it here for you guys to decide what to do with it.

I will take a look if I can find a simple solution. Otherwise I agree – it's probably not worth it to fix this and add a lot of complexity or break lots of other use-cases.