@sankei-arc-shared-components/transform_image-resizer

0.2.0-a • Public • Published

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

Readme

Keywords

none

Package Sidebar

Install

npm i @sankei-arc-shared-components/transform_image-resizer

Weekly Downloads

33

Version

0.2.0-a

License

ISC

Unpacked Size

108 kB

Total Files

15

Last publish

Collaborators

  • sankei.arc