This AssetPreviewStrategy uses the Sharp library to generate preview images of uploaded binary files. For non-image binaries, a generic "file" icon with the mime type overlay will be generated.
By default, this strategy will produce previews up to maximum dimensions of 1600 x 1600 pixels. The created preview images will match the input format - so a source file in jpeg format will output a jpeg preview, a webp source file will output a webp preview, and so on.
The settings for the outputs will default to Sharp's defaults (). However, it is possible to pass your own configurations to control the output of each format:
AssetPreviewStrategy(ctx: RequestContext, mimeType: string, data: Buffer) => Promise<Buffer>This AssetPreviewStrategy uses the Sharp library to generate preview images of uploaded binary files. For non-image binaries, a generic "file" icon with the mime type overlay will be generated.
number1600The max height in pixels of a generated preview image.
number1600The max width in pixels of a generated preview image.
sharp.JpegOptionsv1.7.0Set Sharp's options for encoding jpeg files: https://sharp.pixelplumbing.com/api-output#jpeg
sharp.PngOptionsv1.7.0Set Sharp's options for encoding png files: https://sharp.pixelplumbing.com/api-output#png
sharp.WebpOptionsv1.7.0Set Sharp's options for encoding webp files: https://sharp.pixelplumbing.com/api-output#webp
sharp.GifOptionsv1.7.0Set Sharp's options for encoding gif files: https://sharp.pixelplumbing.com/api-output#gif
sharp.AvifOptionsv1.7.0Set Sharp's options for encoding avif files: https://sharp.pixelplumbing.com/api-output#avif
Architecture reviews, custom plugin work, migrations, ongoing support. Get a hand from the team that builds Vendure.
Talk to the team