-
I'm used to eager-loading Matrix and Asset fields by specifying them as part of an {% do craft.app.elements.eagerLoadElements(
className(entry),
[entry],
[
'myMatrixField',
'myMatrixField.blockType:assetField',
])
%} I'm starting to implement eager-loading for asset transforms, and it would be more maintainable for me to trigger that eager-loading inside the Twig components that render the Just as I can trigger eager-loading of entry fields at any time using the I'm thinking something like this: {# Warning: fictional! #}
{% do craft.app.elements.eagerLoadAssetTransforms(
className(entry.myMatrixField[0].assetField[0]),
[entry.myMatrixField[0].assetField[0]],
[
'square',
{ width: 200, height: 100 },
])
%} Is that currently possible? Am I missing something obvious? I suppose I could pass an instance of an AssetField into my components instead of an Asset (so I could then call |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
I've just found the |
Beta Was this translation helpful? Give feedback.
I've just found the
eagerLoadTransforms
method of the AssetTransforms service class, which seems like it might do what I want, but I'm not sure that service is accessible from the template. I'll keep digging...