mirror of
https://github.com/getgrav/grav.git
synced 2025-10-26 07:56:07 +01:00
@@ -46,7 +46,7 @@
|
||||
"filp/whoops": "~2.9",
|
||||
"matthiasmullie/minify": "^1.3",
|
||||
"monolog/monolog": "~1.25",
|
||||
"getgrav/image": "^3.0",
|
||||
"getgrav/image": "^4.0",
|
||||
"getgrav/cache": "^2.0",
|
||||
"donatj/phpuseragentparser": "~1.1",
|
||||
"pimple/pimple": "~3.5.0",
|
||||
|
||||
@@ -1238,6 +1238,16 @@ form:
|
||||
title: PLUGIN_ADMIN.MEDIA
|
||||
underline: true
|
||||
|
||||
images.adapter:
|
||||
type: select
|
||||
size: small
|
||||
label: PLUGIN_ADMIN.IMAGES_ADAPTER
|
||||
help: PLUGIN_ADMIN.IMAGES_ADAPTER_HELP
|
||||
highlight: gd
|
||||
options:
|
||||
imagick: Imagick
|
||||
gd: GD (PHP built-in)
|
||||
|
||||
images.default_image_quality:
|
||||
type: range
|
||||
append: '%'
|
||||
|
||||
@@ -156,6 +156,7 @@ debugger:
|
||||
close_connection: true # Close the connection before calling onShutdown(). false for debugging
|
||||
|
||||
images:
|
||||
adapter: gd # Image adapter to use: gd | imagick
|
||||
default_image_quality: 85 # Default image quality to use when resampling images (85%)
|
||||
cache_all: false # Cache all image by default
|
||||
cache_perms: '0755' # MUST BE IN QUOTES!! Default cache folder perms. Usually '0755' or '0775'
|
||||
|
||||
@@ -31,6 +31,29 @@ use function in_array;
|
||||
*/
|
||||
class ImageFile extends Image
|
||||
{
|
||||
/**
|
||||
* Image constructor with adapter configuration from Grav.
|
||||
*
|
||||
* @param string|null $originalFile
|
||||
* @param int|null $width
|
||||
* @param int|null $height
|
||||
*/
|
||||
public function __construct($originalFile = null, $width = null, $height = null)
|
||||
{
|
||||
parent::__construct($originalFile, $width, $height);
|
||||
|
||||
// Set the adapter based on Grav configuration
|
||||
$grav = Grav::instance();
|
||||
$adapter = $grav['config']->get('system.images.adapter', 'gd');
|
||||
try {
|
||||
$this->setAdapter($adapter);
|
||||
} catch (Exception $e) {
|
||||
$grav['log']->error(
|
||||
'Image adapter "' . $adapter . '" is not available. Falling back to GD adapter.'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Destruct also image object.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user