@sankei-arc-shared-components/transform_image-resizer
v0.2.0-a
Published
Generates a function which returns image resized urls
Downloads
99
Readme
Generate Image Resizer Function
How do I use it?
This function takes sizePresets and returns a function which returns resizedUrls that use thumbor to do the resizing under the hood.
Here's an example of how to use the function to generate these urls:
import generateResizerFunction from '"@sankei-arc-shared-components/transform_image-resizer';
const RESIZER_URL = 'http://example-resizer-url.com';
const RESIZER_KEY = 'RESIZER_SECRET_KEY';
const sizePresets = {
small: { width: 200, height: 200 },
medium: { width: 600, height: 600 },
large: { width: 1200, height: 1200 },
};
const resizerCriteria = [
[
{ type: 'image' },
'url',
],
];
const resizedUrls = generateResizerFunction(RESIZER_URL, RESIZER_KEY, sizePresets, resizerCriteria);
const images = [{ type: 'image', url: 'www.image.jpg' }, { type: 'image', url: 'www.image2.jpg' }];
resizedUrls(images); // This will returned resizedUrls for those images