2.x Remove unneeded Timber\Image::is_image() method#2669
Merged
Conversation
1 task
Levdbas
previously approved these changes
May 19, 2023
# Conflicts: # src/Image.php
Member
Author
|
Thanks for the feedback here, everyone! |
This file contains hidden or 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
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.
Related:
Issue
While working on #2659, I found that we probably don’t need the
Timber\Image::is_image()method anymore. We now have anis_image()function in the PostFactory:timber/src/Factory/PostFactory.php
Line 173 in 8545e2e
The logic is that if you use
Timber::get_post(), you will only get an instance ofTimber\Image, if it’s an image attachment and aTimber\Attachmentinstance if it’s a non-image attachment.The
Timber\Image::is_image()method is used to check whether a certain function can be used, because it only makes sense for images. But now, if we’re insideTimber\Image, we can assume that we have an image.Solution
Remove the method and where it’s used.
Impact
This is a breaking change, hence the note in the Upgrade Guide.
Usage Changes
Instead of using
Timber\Image::is_image(), we would have to use:Considerations
Using
instanceofdoesn’t work so well in Twig. Should there be anis_image()function inTimber\Post?We could also just remove the
is_image()checks inTimber\Imagean keep the method.Any opinions?
Testing
Covered through existing tests.