[FEATURE] Make the image quality definable per sourceCollection 42/42842/7
authorChristian Seifert <christian-f-seifert@gmx.de>
Thu, 27 Aug 2015 17:54:51 +0000 (19:54 +0200)
committerAlexander Opitz <opitz.alexander@googlemail.com>
Fri, 4 Sep 2015 06:20:28 +0000 (08:20 +0200)
At the moment the image quality of generated jpegs is configured
centrally in LocalConfiguration. Due to trying to find a balance
between image size and image quality it might be useful to enable
the configuration of the image quality for each sourceCollection
entry.

The change set enables users to p.e. render normal images with 90%
and retina images with p.e. 70%. To optionally enable the "quality"
setting for a sourceCollection, TypoScript can be configured as
followed (as example):
tt_content.image.20.1.sourceCollection.smallRetina.quality = 70

If not set, TYPO3 will take the default one of LocalConfiguration.

Resolves: #59591
Releases: master
Change-Id: Ib0e0adf8c2f91471d0ad750c974ad6ed6f41cfa1
Reviewed-on: http://review.typo3.org/42842
Reviewed-by: Markus Klein <markus.klein@typo3.org>
Tested-by: Markus Klein <markus.klein@typo3.org>
Reviewed-by: Alexander Opitz <opitz.alexander@googlemail.com>
Tested-by: Alexander Opitz <opitz.alexander@googlemail.com>
typo3/sysext/core/Documentation/Changelog/master/Feature-59591-ImageQualityDefinablePerSourceCollection.rst [new file with mode: 0644]
typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php

diff --git a/typo3/sysext/core/Documentation/Changelog/master/Feature-59591-ImageQualityDefinablePerSourceCollection.rst b/typo3/sysext/core/Documentation/Changelog/master/Feature-59591-ImageQualityDefinablePerSourceCollection.rst
new file mode 100644 (file)
index 0000000..d41e436
--- /dev/null
@@ -0,0 +1,29 @@
+==============================================================
+Feature: #59591 - Image quality definable per sourceCollection
+==============================================================
+
+Description
+===========
+
+The image quality of each sourceCollection entry can be configured.
+Integrators can already render images with the predefined quality set by LocalConfiguration.
+To decrease the quality of larger images (e.g. double density) in order to lower the file size,
+integrators can configure the parameter "quality" of the matching sourceCollection now.
+
+The TypoScript setup can be configured as followed (e.g.):
+
+.. code-block:: typoscript
+
+       # for small retina images
+       tt_content.image.20.1.sourceCollection.smallRetina.quality = 80
+
+       # for large retina images
+       tt_content.image.20.1.sourceCollection.largeRetina.quality = 65
+
+If the new parameter is not set, TYPO3 will use to the default quality of LocalConfiguration.
+
+
+Impact
+======
+
+The rendering of sourceCollection stays as it is. Users can additionally selectively control the quality of jpeg by TypoScript setup.
index 48e550d..66296b1 100755 (executable)
@@ -1627,6 +1627,16 @@ class ContentObjectRenderer {
                                        'file.' => $conf['file.']
                                );
 
+                               if (isset($sourceConfiguration['quality']) || isset($sourceConfiguration['quality.'])) {
+                                       $imageQuality = isset($sourceConfiguration['quality']) ? $sourceConfiguration['quality'] : '';
+                                       if (isset($sourceConfiguration['quality.'])) {
+                                               $imageQuality = $this->stdWrap($sourceConfiguration['quality'], $sourceConfiguration['quality.']);
+                                       }
+                                       if ($imageQuality) {
+                                               $sourceRenderConfiguration['file.']['params'] = '-quality ' . (int)$imageQuality;
+                                       }
+                               }
+
                                if (isset($sourceConfiguration['pixelDensity'])) {
                                        $pixelDensity = (int)$this->stdWrap($sourceConfiguration['pixelDensity'], $sourceConfiguration['pixelDensity.']);
                                } else {