Skip to content
This repository has been archived by the owner on Jan 4, 2021. It is now read-only.

‚thumb‘ method respecting aspect ratio #605

Open
S1SYPHOS opened this issue Sep 2, 2020 · 0 comments
Open

‚thumb‘ method respecting aspect ratio #605

S1SYPHOS opened this issue Sep 2, 2020 · 0 comments

Comments

@S1SYPHOS
Copy link

S1SYPHOS commented Sep 2, 2020

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

1 participant