Skip to content

Commit

Permalink
[TASK] Add option to exclude images from processing
Browse files Browse the repository at this point in the history
  • Loading branch information
Atomschinken committed May 15, 2024
1 parent 6a79bff commit 61298a6
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 0 deletions.
19 changes: 19 additions & 0 deletions Classes/Xclass/ImageService.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

namespace Sitegeist\ImageJack\Xclass;

use TYPO3\CMS\Core\Resource\FileReference;
use TYPO3\CMS\Core\Resource\ProcessedFile;

class ImageService extends \TYPO3\CMS\Extbase\Service\ImageService
{
public function applyProcessingInstructions($image, array $processingInstructions): ProcessedFile
{
if (is_a($image, FileReference::class)) {
if ($image->hasProperty('tx_imagejack_excluded') && $image->getProperty('tx_imagejack_excluded') === 1) {
$processingInstructions['tx_imagejack_excluded'] = true;
}
}
return parent::applyProcessingInstructions($image, $processingInstructions);
}
}
36 changes: 36 additions & 0 deletions Configuration/TCA/Overrides/sys_file_reference.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

defined('TYPO3') or die;

$newFields = [
'tx_imagejack_excluded' => [
'exclude' => true,
'label' => 'LLL:EXT:image_jack/Resources/Private/Language/backend.xlf:sys_file_reference.tx_imagejack_excluded',
'config' => [
'type' => 'check',
'renderType' => 'checkboxToggle',
'default' => 0
],
]
];

\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTCAcolumns('sys_file_reference', $newFields);
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addFieldsToPalette(
'sys_file_reference',
'imagejackPalette',
'tx_imagejack_excluded'
);
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addToAllTCAtypes(
'sys_file_reference',
'--palette--;;imagejackPalette',
\TYPO3\CMS\Core\Resource\File::FILETYPE_IMAGE
);

if (\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('news')) {
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addFieldsToPalette(
'sys_file_reference',
'imageoverlayPalette',
'--linebreak--,tx_imagejack_excluded',
'after:crop'
);
}
11 changes: 11 additions & 0 deletions Resources/Private/Language/backend.xlf
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<xliff version="1.0">
<file source-language="en" datatype="plaintext" original="messages" date="2024-03-22T11:47:18Z" product-name="image_jack">
<header/>
<body>
<trans-unit id="sys_file_reference.tx_imagejack_excluded" xml:space="preserve">
<source>Exclude from image_jack processing</source>
</trans-unit>
</body>
</file>
</xliff>
5 changes: 5 additions & 0 deletions ext_localconf.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Sitegeist\ImageJack\Templates\WebpTemplate;
use Sitegeist\ImageJack\Templates\AvifTemplate;
use Sitegeist\ImageJack\Xclass\AmazonS3Driver;
use Sitegeist\ImageJack\Xclass\ImageService;
use Sitegeist\ImageJack\Xclass\LocalDriver;
use TYPO3\CMS\Core\Log\Writer\FileWriter;

Expand Down Expand Up @@ -57,4 +58,8 @@
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_fe.php']['createHashBase'][] =
TsfeHook::class . '->postProcessHashBase';
}

$GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects'][\TYPO3\CMS\Extbase\Service\ImageService::class] = [
'className' => ImageService::class
];
});
5 changes: 5 additions & 0 deletions ext_tables.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,8 @@ CREATE TABLE sys_file_processedfile
(
tx_imagejack_processed int(11) DEFAULT '0' NOT NULL
);

CREATE TABLE sys_file_reference
(
tx_imagejack_excluded int(11) DEFAULT '0' NOT NULL
);

0 comments on commit 61298a6

Please sign in to comment.