getkirby-v2 / toolkit

This is the deprecated toolkit for Kirby v2.
http://getkirby.com
81 stars 50 forks source link

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

Closed texnixe closed 4 years ago

texnixe commented 6 years ago

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

lukasbestle commented 6 years ago

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?

texnixe commented 6 years ago

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.

lukasbestle commented 6 years ago

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.