Source of file ImageResamplingSetting.php
Size: 1,400 Bytes - Last Modified: 2020-11-13T10:29:06+00:00
/var/www/docs.ssmods.com/process/src/src/Models/Settings/ImageResamplingSetting.php
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 | <?php namespace Nobrainer\Elemental\Settings; use SilverStripe\Assets\Image; use SilverStripe\Forms\DropdownField; class ImageResamplingSetting extends ElementSettingExtension { private static $title = 'Image Resampling'; private static $column = 'ImageResampling'; private static $defaultValue = 'Fill'; private static $db = [ 'ImageResampling' => 'Text' ]; private static $settings = [ 'Method' => [ 'field' => DropdownField::class, 'source' => [ 'Fill' => 'Fyld', 'ScaleWidth' => 'Fuld højde', 'ScaleHeight' => 'Skaler højde', 'ScaleMaxHeight' => 'Skaler max-højde', ] ], ]; public function ResampledImage($id, $width, $height) { if (!$id) { return ''; } $image = Image::get_by_id($id); if (!$image) { return ''; } $object = $this->getColumnObject(); $method = $object->Method; switch ($method) { case 'Fill': case 'ScaleWidth': return $image->$method($width, $height); case 'ScaleHeight': case 'ScaleMaxHeight': return $image->$method($height); default: return $image->Fill($width, $height); } } } |