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
Add a createIfDeferred() method to the ImageResult class #2368
Merged
leofeyer
merged 8 commits into
contao:master
from
m-vo:feature/studio-create-if-deferred
Oct 14, 2020
Merged
Add a createIfDeferred() method to the ImageResult class #2368
leofeyer
merged 8 commits into
contao:master
from
m-vo:feature/studio-create-if-deferred
Oct 14, 2020
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ausi
reviewed
Sep 28, 2020
ausi
reviewed
Sep 28, 2020
ausi
reviewed
Sep 28, 2020
ausi
reviewed
Sep 28, 2020
ausi
previously approved these changes
Sep 28, 2020
Toflar
reviewed
Sep 28, 2020
return; | ||
} | ||
|
||
$resizer = $this->resizer(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't we check this first? If the resizer isn't available, we don't need to collect any $deferredImages
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see #2368 (comment)
leofeyer
previously approved these changes
Oct 9, 2020
leofeyer
force-pushed
the
feature/studio-create-if-deferred
branch
from
October 9, 2020 15:19
0a0b2b0
to
412ce3e
Compare
leofeyer
approved these changes
Oct 9, 2020
ausi
approved these changes
Oct 13, 2020
Thank you @m-vo. |
leofeyer
changed the title
Add createIfDeferred to ImageResult
Add a createIfDeferred() method to the ImageResult class
Jan 18, 2021
AlexejKossmann
pushed a commit
to AlexejKossmann/contao
that referenced
this pull request
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This adds the ability to synchronously trigger the creation of resized images from within an
ImageResult
. This is similar toFile#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 thecontao.image.resizer
service does not support deferred resizing (DeferredResizerInterface
) and exceptions won't be swallowed.Demo Usage: