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

Force creation of Image #2144

wants to merge 1 commit into from

Conversation

tsarma
Copy link
Contributor

@tsarma tsarma commented May 29, 2020

Contao 4.8 introduced a Deferred image resizing concept to boost performance. This may cause issue like no product image in Isotope Invoice PDF.

Contao 4.8 introduced a Deferred image resizing concept to boost performance. This may cause issue like no product image in Isotope Invoice PDF.
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.

@aschempp
Copy link
Member

If I understand correctly, this would always create all images for all galleries of all products? So deferred images would essentially be lost for Isotope?
Shouldn't we rather just create the images that are used in a document/PDF?

@fritzmg
Copy link
Contributor

fritzmg commented May 29, 2020

True, it should only be done for the generation of images when creating a document.

@tsarma
Copy link
Contributor Author

tsarma commented May 29, 2020

If I understand correctly, this would always create all images for all galleries of all products? So deferred images would essentially be lost for Isotope?

Yes.

Shouldn't we rather just create the images that are used in a document/PDF?

Ideally yes. There is at the moment no way of knowing from where the image is called. As it is always called inside a template, which can be used by both PDF and website.

I think a possible solution might be to change method generateMainImage() signature. public function generateMainImage($createDeferredImage = false)

@fritzmg
Copy link
Contributor

fritzmg commented May 29, 2020

You could check for TL_MODE. When generating the PDF, it will be BE, otherwise FE, presumably.

@tsarma
Copy link
Contributor Author

tsarma commented May 29, 2020

You could check for TL_MODE. When generating the PDF, it will be BE, otherwise FE, presumably.

Is it so? Also for checkout process, where I generate PDF to send with order email?

@fritzmg
Copy link
Contributor

fritzmg commented May 29, 2020

Hm, you are right, that won't work. The dirty way would be to define a scope via $GLOBALS or something within the document generation …

@ausi
Copy link

ausi commented Jun 2, 2020

I think we should fix that when creating the PDF document in https://github.com/isotope/core/blob/master/system/modules/isotope/library/Isotope/Model/Document/Standard.php#L220

if (method_exists(File::class, 'createIfDeferred')) {
    (new File(rawurldecode($args[2])))->createIfDeferred();
}

@aschempp
Copy link
Member

aschempp commented Jun 2, 2020

I have implemented @ausi's fix in a754933, @tsarma can you check if this works?

@aschempp aschempp added this to the 2.6.13 milestone Jun 2, 2020
@aschempp aschempp added the bug label Jun 2, 2020
@tsarma
Copy link
Contributor Author

tsarma commented Jun 2, 2020

Yes, it works with @ausi's fix. Thank you

@tsarma tsarma closed this Jun 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants