1.0.2 • Published 4 years ago

storyblok-images v1.0.2

Weekly downloads
2
License
ISC
Repository
github
Last release
4 years ago

:framed_picture: Storyblok Images

npm.io npm.io npm.io npm.io

Resize and use all the storyblok images service operations easily.

Instalation

Install the package using npm...

npm install --save storyblok-images

or yarn

yarn add storyblok-images

Basic example

import storyblokImages from 'storyblok-images'

const resizedImage = storyblokImages({
  url: 'https://a.storyblok.com/f/39898/3310x2192/e4ec08624e/demo-image.jpeg', // Image uploaded to Storyblok
  size: {
    // Resize to
    width: 200,
    height: 300,
  },
})

// resizedImage = https://img2.storyblok.com/200x300/f/39898/3310x2192/e4ec08624e/demo-image.jpeg

The configuration object

The configuration object accepts the following values:

FieldRequiredTypeDefaultExample
urltrueStringhttps://a.storyblok.com/f/39898/3310x2192/e4ec08624e/demo-image.jpeg
sizefalse{width: Number, height: Number}{ width: 100, height: 200 }
fitInfalseBooleanfalsefalse
fillfalseString'''cccccc'
formatfalseString. Valid values: 'webp', 'jpeg' and 'png''webp'
qualityfalseNumber. From 1 to 10040
smartCropfalseBooleanfalsefalse
focalPointsfalseMatrix [number, number, number, number][100, 100, 20, 30]

:ledger: Chech storyblok images service for further details on what any of this fields do.

Contributing

PRs welcome! Please, follow Prettier rules included in .vscode

Running tests:

npm test

Or

yarn test

Thanks! :v: