Skip to content
Everett Griffiths edited this page Jul 8, 2014 · 9 revisions

scale2w

The "scale2w" Snippet is an output filter that operates on an asset ID and returns a URL to the image of the desired size. It scales the asset to a desired width and calculates the height to preserve the aspect ratio of the original image. This request will trigger the desired image size to be generated if it does not exist already.

Arguments

Specify the desired width as an integer (in pixels).

Example

Normally, the asset_id parameter would be supplied via the getPageAssets Snippet, so the following might be used inside a formatting Chunk where "asset_id" was available as a placeholder:

[[getPageAssets? 
    &innerTpl=`<img src="[[+asset_id:scale2w=`600`]]" width="600" height="[[+asset_id.height]]" />`
]]

The calculated width is available as a placeholder: [[+asset_id.width]]

Although unconventional, it is possible to call the scale2w Snippet as a stand-alone Snippet and not as an output filter. This is useful if you wanted to display a single asset at a desired size. In the example below, asset ID 123 will be resized to a width of 600.

<img src="[[scale2w? &input=`123` &options=`600`]]" width="600" height="[[+asset_id.height]]" />
Clone this wiki locally