Skip to content

Commit

Permalink
Merge pull request #97 from sitegeist/task/96/preventHugeInlinePlaceh…
Browse files Browse the repository at this point in the history
…older

[TASK] Check processed placeholder to prevent large inline images
  • Loading branch information
s2b authored Feb 21, 2022
2 parents 2eb82c8 + 3e7ff5e commit c5358ef
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
5 changes: 5 additions & 0 deletions Classes/Utility/ResponsiveImagesUtility.php
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,11 @@ public function generatePlaceholderImage(
}
$processedImage = $this->imageService->applyProcessingInstructions($image, $processingInstructions);

// Disable inline placeholder if the image is not processed at all
if ($processedImage->usesOriginalFile()) {
$inline = false;
}

if ($inline) {
return $this->generateDataUri($processedImage);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ protected function mockFileObject($properties, $processed = false)

$fileMock = $this->getMockBuilder($processed ? ProcessedFile::class : FileReference::class)
->disableOriginalConstructor()
->setMethods(['getProperty', 'getMimeType', 'getContents'])
->setMethods(['getProperty', 'getMimeType', 'getContents', 'usesOriginalFile'])
->getMock();

$fileMock
Expand All @@ -90,6 +90,11 @@ protected function mockFileObject($properties, $processed = false)
->will($this->returnCallback(function () use ($properties) {
return 'das-ist-der-dateiinhalt';
}));
$fileMock
->method('usesOriginalFile')
->will($this->returnCallback(function () use ($properties) {
return false;
}));

return $fileMock;
}
Expand Down
2 changes: 1 addition & 1 deletion ext_emconf.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
'state' => 'stable',
'uploadfolder' => false,
'clearCacheOnLoad' => false,
'version' => '2.1.2',
'version' => '2.1.3',
'constraints' => [
'depends' => [
'typo3' => '9.5.0-11.9.99',
Expand Down

0 comments on commit c5358ef

Please sign in to comment.