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
Consider adding createIfDeferred to ImageResult
#2322
Comments
leofeyer
pushed a commit
that referenced
this issue
Oct 14, 2020
Description ----------- | Q | A | -----------------| --- | Fixed issues | Closes #2322 | Docs PR or issue | Todo This adds the ability to synchronously trigger the creation of resized images from within an `ImageResult`. This is similar to `File#createIfDeferred()` but processes all resources (picture img + picture sources) instead of a single file. Contrary to the method in `File` an exception will be thrown if the `contao.image.resizer` service does not support deferred resizing (`DeferredResizerInterface`) and exceptions won't be swallowed. **Demo Usage:** ```php $figure = $studio->createFigureBuilder() ->fromPath('files/public/foo.jpg') ->setSize('_my_size') ->build(); $figure->getImage()->createIfDeferred(); // It's now safe to access any of the generated image files directly $pdf->addImage($figure); ``` Commits ------- 5ffb194 add contao.image.resizer to studio locator 45815c6 add createIfDeferred method to ImageResult 9c02354 adjust ContaoCoreExtensionTest 71ffe3f also scan for 'srcset' elements (+ remove duplicates) b73ba71 do not throw exception if there are no deferred images 4f30e2f simplify getting candidates + remove duplicate check 6f0b976 CS 412ce3e Merge branch 'master' into feature/studio-create-if-deferred
AlexejKossmann
pushed a commit
to AlexejKossmann/contao
that referenced
this issue
Apr 6, 2021
Description ----------- | Q | A | -----------------| --- | Fixed issues | Closes contao#2322 | Docs PR or issue | Todo This adds the ability to synchronously trigger the creation of resized images from within an `ImageResult`. This is similar to `File#createIfDeferred()` but processes all resources (picture img + picture sources) instead of a single file. Contrary to the method in `File` an exception will be thrown if the `contao.image.resizer` service does not support deferred resizing (`DeferredResizerInterface`) and exceptions won't be swallowed. **Demo Usage:** ```php $figure = $studio->createFigureBuilder() ->fromPath('files/public/foo.jpg') ->setSize('_my_size') ->build(); $figure->getImage()->createIfDeferred(); // It's now safe to access any of the generated image files directly $pdf->addImage($figure); ``` Commits ------- 5ffb194 add contao.image.resizer to studio locator 45815c6 add createIfDeferred method to ImageResult 9c02354 adjust ContaoCoreExtensionTest 71ffe3f also scan for 'srcset' elements (+ remove duplicates) b73ba71 do not throw exception if there are no deferred images 4f30e2f simplify getting candidates + remove duplicate check 6f0b976 CS 412ce3e Merge branch 'master' into feature/studio-create-if-deferred
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
We should imo consider adding a
createIfDeferred
method (working like the one inFile
) to theImageResult
class as well, so that you can easily use theFigureBuilder
concept for documents, emails or other occations where the result shouldn't be fetched from the server.The text was updated successfully, but these errors were encountered: