-
Notifications
You must be signed in to change notification settings - Fork 9
Transform
The transform
filter can be used to bulk transform any <img>
tag inside HTML content. The filter accepts both inline and named transforms.
If you have the excellent Imager plugin by @aelvan installed (or its successor, Imager X), Retcon will use that to apply the transform.
If you don't use Imager, please note that Retcon will not transform external images (Imager will, though!).
Named transforms
{{ entry.body | retconTransform( 'yourNamedTransform' ) }}
Inline transforms
{{ entry.body | retconTransform( { width : 1024, height : 768, mode : 'fit' } ) }}
Full example
Input: <img src="/uploads/images/image.jpg" />
Filter: {{ content | retconTransform( 'someTransform' ) }}
Output: <img src="/uploads/images/_someTransform/image.jpg />
@transform mixed
Handle for named transform (String), or Array containing transform properties
@selector string|string[]
String value or array of string values. Optional, default "img"
The transformed is applied to all (local) images; the transformed version is stored in the same folder as the original, under a subfolder named after the transform handle or a concatenation of transform properties (unless a different base path for transforms is set in the plugin's settings).
https://craftcms.com/docs/3.x/image-transforms.html https://imager-x.spacecat.ninja/overview.html