From 56a8be54b2e729aece8c6cbf3a39e3827c651267 Mon Sep 17 00:00:00 2001 From: Christian Weiske Date: Mon, 16 Apr 2018 20:27:04 +0200 Subject: [PATCH] Add default configuration for images This patch allows configuring image processing instructions for all images. A use case is generating a fixed set of sizes (derivatives) for all images, without having to specify them in the content markdown. Example configuration in user/config/system.yaml: images: defaults: derivatives: "[300,600,1200]" --- system/src/Grav/Common/Helpers/Excerpts.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/system/src/Grav/Common/Helpers/Excerpts.php b/system/src/Grav/Common/Helpers/Excerpts.php index d774bcf463..3561bc365c 100644 --- a/system/src/Grav/Common/Helpers/Excerpts.php +++ b/system/src/Grav/Common/Helpers/Excerpts.php @@ -294,6 +294,15 @@ public static function processMediaActions($medium, $url) if (Grav::instance()['config']->get('system.images.auto_fix_orientation')) { $actions[] = ['method' => 'fixOrientation', 'params' => '']; } + $defaults = Grav::instance()['config']->get('system.images.defaults'); + if (is_array($defaults) && count($defaults)) { + foreach ($defaults as $method => $params) { + $actions[] = [ + 'method' => $method, + 'params' => $params, + ]; + } + } // loop through actions for the image and call them foreach ($actions as $action) {