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

Force creation of Image #2144

Closed
wants to merge 1 commit into from
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,18 @@ protected function getImageForType($strType, array $arrFile, $blnWatermark = tru

try {
$strImage = \Image::create($strFile, $size)->executeResize()->getResizedPath();
$picture = \Picture::create($strFile, $size)->getTemplateData();

if (!is_file(TL_ROOT . '/' . $strImage)) {
$image = \System::getContainer()->get('contao.image.image_factory')->create(TL_ROOT . '/' . $strImage);
\System::getContainer()->get('contao.image.resizer')->resizeDeferredImage($image);
}

$picture = \Picture::create($strFile, $size)->getTemplateData();

if (!is_file(TL_ROOT . '/' . $picture['img']['src'])) {
$src = \System::getContainer()->get('contao.image.image_factory')->create(TL_ROOT . '/' . $picture['img']['src']);
\System::getContainer()->get('contao.image.resizer')->resizeDeferredImage($src);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about images in a srcset or multiple <source>s? I mean, not that it really matters for PDF creation, but technically all the sources would neet to be resized in advance.

/cc @ausi

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

srcset is used only in browsers. There we don't have any problems. The problem is only in PDF generation.

} catch (\Exception $e) {
\System::log('Image "' . $strFile . '" could not be processed: ' . $e->getMessage(), __METHOD__, TL_ERROR);

Expand Down