diff --git a/system/blueprints/config/system.yaml b/system/blueprints/config/system.yaml index 1fb67d131..b0ad371d0 100644 --- a/system/blueprints/config/system.yaml +++ b/system/blueprints/config/system.yaml @@ -1300,6 +1300,17 @@ form: auto: Auto lazy: Lazy eager: Eager + + images.defaults.decoding: + type: select + size: small + label: PLUGIN_ADMIN.IMAGES_DECODING + help: PLUGIN_ADMIN.IMAGES_DECODING_HELP + highlight: auto + options: + auto: Auto + sync: Sync + async: Async images.seofriendly: type: toggle diff --git a/system/config/system.yaml b/system/config/system.yaml index 8bcc28075..3495c448b 100644 --- a/system/config/system.yaml +++ b/system/config/system.yaml @@ -168,6 +168,7 @@ images: retina_scale: 1 # scale to adjust auto-sizes for better handling of HiDPI resolutions defaults: loading: auto # Let browser pick [auto|lazy|eager] + decoding: auto # Let browser pick [auto|sync|async] watermark: image: 'system://images/watermark.png' # Path to a watermark image position_y: 'center' # top|center|bottom diff --git a/system/src/Grav/Common/Media/Traits/ImageDecodingTrait.php b/system/src/Grav/Common/Media/Traits/ImageDecodingTrait.php new file mode 100644 index 000000000..7ea01e91c --- /dev/null +++ b/system/src/Grav/Common/Media/Traits/ImageDecodingTrait.php @@ -0,0 +1,40 @@ +get('system.images.defaults.decoding', 'auto'); + } + + // Validate the provided value (similar to loading) + if ($value !== null && $value !== 'auto') { + $this->attributes['decoding'] = $value; + } + + return $this; + } + +} \ No newline at end of file diff --git a/system/src/Grav/Common/Page/Medium/ImageMedium.php b/system/src/Grav/Common/Page/Medium/ImageMedium.php index 30e369b7f..4de211bee 100644 --- a/system/src/Grav/Common/Page/Medium/ImageMedium.php +++ b/system/src/Grav/Common/Page/Medium/ImageMedium.php @@ -15,6 +15,7 @@ use Grav\Common\Media\Interfaces\ImageMediaInterface; use Grav\Common\Media\Interfaces\MediaLinkInterface; use Grav\Common\Media\Traits\ImageLoadingTrait; +use Grav\Common\Media\Traits\ImageDecodingTrait; use Grav\Common\Media\Traits\ImageMediaTrait; use Grav\Common\Utils; use Gregwar\Image\Image; @@ -30,6 +31,7 @@ class ImageMedium extends Medium implements ImageMediaInterface, ImageManipulate { use ImageMediaTrait; use ImageLoadingTrait; + use ImageDecodingTrait; /** * @var mixed|string