getkirby / ideas

This is the backlog of ideas and feature requests from the last two years. Use our new feedback platform to post your new ideas or vote on existing ideas.
https://feedback.getkirby.com
20 stars 0 forks source link

‚thumb‘ method respecting aspect ratio #605

Open S1SYPHOS opened 4 years ago

S1SYPHOS commented 4 years ago

Hey there, since I couldn't find anything really targeting what I need, here's a thought: How about passing an aspect ratio to thumb, which makes it

  1. take either width or height (if both specified, well, ignore height or so)
  2. calculate width/height based on desired aspect ratio &
  3. crop image accordingly?
$preset = [
  'width' => 200,
  'ratio' => '2/1' // .. or float
];
$thumb = $file->thumb($preset);

// $thumb->height() equals 100

I want to be able to specify a certain aspect ratio without having to fetch the preset's width or height attribute - doing this would remove the advantage of having presets in the first place.

Furthermore, using different srcset presets, manually calculating values for all sizes is just too tedious.

Maybe there's a simple(r) approach, feedback welcome as always.

Cheers, S1SYPHOS