Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUGFIX] match handling of gallery processing with core #513

Merged
merged 2 commits into from
Nov 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion Classes/DataProcessing/FilesProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,13 @@ protected function processFiles(array $properties = []): ?array

foreach ($this->fileObjects as $key => $fileObject) {
if (isset($this->processorConfiguration['processingConfiguration.']['autogenerate.'])) {
$file = $this->getFileUtility()->processFile($fileObject, $properties, $cropVariant);
$file = $this->getFileUtility()->processFile(
$fileObject,
$properties,
$cropVariant,
(int)($this->processorConfiguration['processingConfiguration.']['delayProcessing'] ?? 0) === 1
);

$targetWidth = (int)($properties['width'] ?: $file['properties']['dimensions']['width']);
$targetHeight = (int)($properties['height'] ?: $file['properties']['dimensions']['height']);

Expand Down
4 changes: 2 additions & 2 deletions Classes/DataProcessing/GalleryProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,8 @@ protected function prepareGalleryData()
$fileObj = $this->fileObjects[$fileKey] ?? null;

if ($fileObj) {
if (($this->equalMediaWidth || $this->equalMediaHeight) && $fileObj['properties']['type'] === 'image') {
$image = $this->getImageService()->getImage($fileObj['properties']['originalUrl'], null, true);
if ($fileObj['properties']['type'] === 'image') {
$image = $this->getImageService()->getImage((string)$fileObj['properties']['fileReferenceUid'], null, true);
$fileObj = $this->getFileUtility()->processFile($image, $this->mediaDimensions[$fileKey] ?? []);

if (isset($this->processorConfiguration['autogenerate.']['retina2x'],
Expand Down
6 changes: 2 additions & 4 deletions Classes/Utility/FileUtility.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,10 @@ public function __construct(
}

/**
* @param FileInterface $fileReference
* @param array $dimensions
* @param string $cropVariant
* @return array
*/
public function processFile(FileInterface $fileReference, array $dimensions = [], string $cropVariant = 'default'): array
public function processFile(FileInterface $fileReference, array $dimensions = [], string $cropVariant = 'default', bool $delayProcessing = false): array
{
$fileReferenceUid = $fileReference->getUid();
$uidLocal = $fileReference->getProperty('uid_local');
Expand All @@ -107,7 +105,7 @@ public function processFile(FileInterface $fileReference, array $dimensions = []
];

if ($fileRenderer === null && $fileReference->getType() === AbstractFile::FILETYPE_IMAGE) {
if ($fileReference->getMimeType() !== 'image/svg+xml') {
if (!$delayProcessing && $fileReference->getMimeType() !== 'image/svg+xml') {
$fileReference = $this->processImageFile($fileReference, $dimensions, $cropVariant);
}
$publicUrl = $this->imageService->getImageUri($fileReference, true);
Expand Down
3 changes: 3 additions & 0 deletions Configuration/TypoScript/ContentElement/Image.typoscript
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ tt_content.image {
10 {
references.fieldName = image
as = files
processingConfiguration {
delayProcessing = 1
}
}
20 = FriendsOfTYPO3\Headless\DataProcessing\GalleryProcessor
20 {
Expand Down
3 changes: 3 additions & 0 deletions Configuration/TypoScript/ContentElement/Textmedia.typoscript
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ tt_content.textmedia {
10 {
references.fieldName = assets
as = files
processingConfiguration {
delayProcessing = 1
}
}
20 = FriendsOfTYPO3\Headless\DataProcessing\GalleryProcessor
20 {
Expand Down
3 changes: 3 additions & 0 deletions Configuration/TypoScript/ContentElement/Textpic.typoscript
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ tt_content.textpic {
10 {
references.fieldName = image
as = files
processingConfiguration {
delayProcessing = 1
}
}
20 = FriendsOfTYPO3\Headless\DataProcessing\GalleryProcessor
20 {
Expand Down