Skip to content

Commit

Permalink
Merge pull request #4 from netlogix/feature/hide-web-images-in-file-a…
Browse files Browse the repository at this point in the history
…dmin

FEATURE: Hide webp files in file list
  • Loading branch information
stephanschuler authored Sep 17, 2020
2 parents 63056c9 + 3bfd3a0 commit 7b72c29
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 4 deletions.
26 changes: 26 additions & 0 deletions Classes/Fal/Filter/GeneratedFileNamesFilter.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php
declare(strict_types=1);

namespace Netlogix\Nximageoptimizer\Fal\Filter;

use TYPO3\CMS\Core\Resource\Driver\DriverInterface;
use TYPO3\CMS\Core\Resource\Driver\LocalDriver;

class GeneratedFileNamesFilter
{
public static function filterGeneratedFiles(
$itemName,
$itemIdentifier,
$parentIdentifier,
array $additionalInformation,
DriverInterface $driverInstance
) {
if (!$driverInstance instanceof LocalDriver) {
return true;
}
if (preg_match('%.+\.(jpe?g|png)\.webp$%i', $itemName)) {
return -1;
}
return true;
}
}
2 changes: 1 addition & 1 deletion Classes/Service/ImageService.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class ImageService extends \TYPO3\CMS\Extbase\Service\ImageService
/**
* @inheritdoc
*/
public function applyProcessingInstructions($image, array $processingInstructions): ProcessedFile
public function applyProcessingInstructions($image, $processingInstructions): ProcessedFile
{
$quality = MathUtility::forceIntegerInRange($GLOBALS['TYPO3_CONF_VARS']['GFX']['jpg_quality'], 10, 100, 75);
if ($image->getMimeType() === 'image/png') {
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"type": "typo3-cms-extension",
"description": "Optimize images when they are processed by the resource publisher",
"require": {
"typo3/cms-core": "^10.4"
"typo3/cms-core": "~8.7.0 || ~9.5.0 || ^10.4"
},
"autoload": {
"psr-4": {
Expand Down
4 changes: 2 additions & 2 deletions ext_emconf.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@
'author_company' => '',
'CGLcompliance' => '',
'CGLcompliance_note' => '',
'version' => '3.0.0',
'version' => '3.1.0',
'_md5_values_when_last_written' => '',
'constraints' => [
'depends' => [
'typo3' => '10.4.0-10.99.99',
'typo3' => '8.7.0-9.5.99,10.4.0-10.99.99',
],
'conflicts' => [],
'suggests' => []
Expand Down
5 changes: 5 additions & 0 deletions ext_localconf.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,9 @@
],
];

$GLOBALS['TYPO3_CONF_VARS']['SYS']['fal']['defaultFilterCallbacks'][\Netlogix\Nximageoptimizer\Fal\Filter\GeneratedFileNamesFilter::class] = [
\Netlogix\Nximageoptimizer\Fal\Filter\GeneratedFileNamesFilter::class,
'filterGeneratedFiles'
];

})();

0 comments on commit 7b72c29

Please sign in to comment.