0.5.2 • Published 4 years ago
ipx-client v0.5.2
IPX Client for Node.js and Browser
See IPX for more information.
Install package:
npm i ipx-client
yarn install ipx-client
Import client:
import { img } from 'ipx-client'
const { img } = require('ipx-client')
img()
is a factory function to configure base options:
// getImage: (path, opts?, format?) => URL
const getImage = img({
baseURL = 'https://cdn.example.com',
basePath = 'uploads',
opts = [], // Default opts
format = 'jpg',
presets: {
chrome400: {
format: 'webp',
opts: { s: ['400', '400']}
}
}
})
getImage('posts/ipx.png', { w: 200 }) // => https://cdn.example.com/jpg/w_200/uploads/posts/ipx.png
getImage.chrome400('posts/ipx.png') // => https://cdn.example.com/webp/s_400_400/uploads/posts/ipx.png