You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I want to determine simply if an image thumbnail file has been provided following the filename pattern [image-name].[extension].thumb.[ext] described in Thumbnail Location, item 1.
I have found that the expression image.items.thumbnails.page is defined happens to tell me if the thumbnail file is provided, but this isn't obvious or elegant.
Maybe a separate issue: I expected [image].thumbnail('page') in Twig to return null or be undefined when a thumbnail file isn't provided, and that would have been the obvious test. However, I noticed that the expression [image].thumbnail('page').display('thumbnail').html falls back to the same as [image].thumbnail('media').display('thumbnail').html in those cases. Whether intended behaviour or not, for me it's not a helpful fallback and not intuitive.
So, to simplify, possibly 2 things to investigate:
an official/idiomatic Twig function or mechanism to detect presence of thumbnail file
[image].thumbnail('page').display('thumbnail').html shouldn't fall back to the image medium's HTML when a thumbnail file isn't provided
The text was updated successfully, but these errors were encountered:
I think that it's actually better to have a method on the media object to tell if a thumbnail exists.. This might be buried in there already, need to look.
Sure, you could sidestep the second issue by testing the first, but only as long as you are aware of the second issue behaviour. I think the second may trip a few up, however.
Thanks, look forward to the results of investigating :)
Added new method for next release to check for thumbnail.
regarding issue #2, i don't want to change this behavior at this point as people might be depending on it (accidentally or intentionally). Something for Grav 2.0 to improve.
I want to determine simply if an image thumbnail file has been provided following the filename pattern
[image-name].[extension].thumb.[ext]
described in Thumbnail Location, item 1.I have found that the expression
image.items.thumbnails.page is defined
happens to tell me if the thumbnail file is provided, but this isn't obvious or elegant.Maybe a separate issue: I expected
[image].thumbnail('page')
in Twig to return null or be undefined when a thumbnail file isn't provided, and that would have been the obvious test. However, I noticed that the expression[image].thumbnail('page').display('thumbnail').html
falls back to the same as[image].thumbnail('media').display('thumbnail').html
in those cases. Whether intended behaviour or not, for me it's not a helpful fallback and not intuitive.So, to simplify, possibly 2 things to investigate:
[image].thumbnail('page').display('thumbnail').html
shouldn't fall back to the image medium's HTML when a thumbnail file isn't providedThe text was updated successfully, but these errors were encountered: