imagecache icon indicating copy to clipboard operation
imagecache copied to clipboard

Added possibility to define Templates with arguments

Open eightyfive opened this issue 9 years ago • 2 comments
trafficstars

Hi,

I added what I believe is a simple yet very helpful trick. But I obviously may not see the entire picture.

That would fully resolve issues like this one: https://github.com/Intervention/image/issues/368

And would still hold the security argument: https://github.com/Intervention/image/issues/241

See basic example:

'templates' => array(
      'small' => 'Intervention\Image\Templates\Small',
      'medium' => 'Intervention\Image\Templates\Medium',
      'large' => 'Intervention\Image\Templates\Large'
  )

Would become:

use Intervention\Image\Templates\Fit;

'templates' => array(
      'small' => [Fit::class, 120, 90],
      'medium' => [Fit::class, 240, 180],
      'large' => [Fit::class, 480, 360]
  )

And would allow easy customisation.

What are your thoughts?

eightyfive avatar Mar 31 '16 10:03 eightyfive

Does it make sense?

The problem I was facing is that I had to create a new Template for every different parameters combination of a given image transformation (which is exactly the problem of the documentation example: small, medium, large are all the same transformation).

eightyfive avatar Apr 08 '16 08:04 eightyfive

Up.

eightyfive avatar May 12 '16 06:05 eightyfive