2.2.0 • Published 5 years ago

thumbor-js-url-builder v2.2.0

Weekly downloads
57
License
MIT
Repository
github
Last release
5 years ago

Thumbor URL builder

Thumbor client for JavaScript.

Installation

npm i thumbor-js-url-builder

Declare in JS

import Thumbor from 'thumbor-js-url-builder'
const thumbor = new Thumbor('my_key', 'https://my-site.com/thumbs')

Generate your URL

const thumborize = thumbor
  .filter('format(webp)')
  .setImagePath('https://my-site.com/image.jpeg')
  .resize(600, 400)
  .buildUrl()

Example

// .env

thumborKey="gr4mf3t3gsg4g3g3d3d"
thumborUrl="https://my-site.com/thumbs"

// thumborize.js 

import Thumbor from 'thumbor-js-url-builder'
const thumbor = new Thumbor(process.env.thumborKey, process.env.thumborUrl)

const thumborize = (type = 'jpeg', url, num = 1, width = 600, height = 400) => {
  return thumbor
    .filter(`format(${type})`)
    .setImagePath(url)
    .resize(width * num, height * num)
    .buildUrl()
}

export default thumborize
2.2.0

5 years ago

2.1.8

5 years ago

2.1.7

5 years ago

2.1.6

5 years ago

2.1.5

5 years ago

2.1.4

5 years ago

2.1.2

5 years ago

2.0.1

5 years ago

2.0.0

5 years ago

1.0.0

5 years ago