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
Iterating over an "assets" field (multiple assets) using a "scope" attribute, cast the image data to an array.
If we want to use glide tags we have to be careful because glide does support "Asset entry" or "relative url" as it's "src" param (see #https://statamic.dev/tags/glide#asset) , but not an array :
{{ images scope="img" }}
{{# here "img" is an array, so we cannot do that : #}}
{{ glide :src="img" w="100" h="100" }}
{{ /images }}
we can of course use "img.url" instead of "img", but it's frequent to use a dedicated "partial" to manage glide manipulation, and passing it only one image param, so we need to be carefull of the type of data. And it happens, we want to use glide with "public url" and not an asset field, so using the "img.url" notation does not always work...
For instance, if we have an "asset" field (containing only one asset), we can do that :
{{ glide :src="img" w="100" h="100" }}
{# it works because img is an asset field supprted by glide, it would also work if img would be a public url string #}
So I guess my question is : when iterating over an "assets field" (multiple assets) using a "scope" param, do we need to cast each asset to an array ? Can't we just receive the "asset entry" directly ?
Also casting each variable to an array, does also trigger full augmentation, which might cause some performance issues... I guess we could be clever and detect the type of data being iterated over, to cast it to the more appropriate datatype (asset entry, entry, or whatever, and falling back to an array when needed)
Bug description
Iterating over an "assets" field (multiple assets) using a "scope" attribute, cast the image data to an array.
If we want to use glide tags we have to be careful because glide does support "Asset entry" or "relative url" as it's "src" param (see #https://statamic.dev/tags/glide#asset) , but not an array :
we can of course use "img.url" instead of "img", but it's frequent to use a dedicated "partial" to manage glide manipulation, and passing it only one image param, so we need to be carefull of the type of data. And it happens, we want to use glide with "public url" and not an asset field, so using the "img.url" notation does not always work...
For instance, if we have an "asset" field (containing only one asset), we can do that :
So I guess my question is : when iterating over an "assets field" (multiple assets) using a "scope" param, do we need to cast each asset to an array ? Can't we just receive the "asset entry" directly ?
Also casting each variable to an array, does also trigger full augmentation, which might cause some performance issues... I guess we could be clever and detect the type of data being iterated over, to cast it to the more appropriate datatype (asset entry, entry, or whatever, and falling back to an array when needed)
What do you think ?
How to reproduce
just read the bellow examples
Logs
No response
Environment
Installation
Fresh statamic/statamic site via CLI
Additional details
No response
The text was updated successfully, but these errors were encountered: