Socket
Book a DemoInstallSign in
Socket

react-thumbor-img

Package Overview
Dependencies
Maintainers
2
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-thumbor-img

A React Component that generates images with valid Thumbor URLs for you.

4.0.3
latest
Source
npmnpm
Version published
Weekly downloads
174
-5.95%
Maintainers
2
Weekly downloads
 
Created
Source

react-thumbor-img

You like React? But you use Thumbor?

Worry not, because you have now found the perfect library to use both together in a nice simple component. It currently handles only unsafe URLs, as safe URLs cannot be generated in the client side.

Usage

Usage is simple, very simple:

import React from 'react'
import { ThumborImage } from 'react-thumbor-img'

function MyAwesomeSection(props) {
	return <section>
			<ThumborImage
				server='http://mythumborserver.com'
				src='http://imagestorage/imageurl.jpg'
				height={200}
				width={300}
			/>
		</section>
}

Properties for ThumborImage

server(required): URL of your thumbor server

src(required): URI of the original picture

generateSrcSet: If true, will generate a srcset attribute for the image that will contain 2x and 3x versions of the picture automatically. default: true

width: width in pixel for the standard size of the picture. Use 0 to indicate it should be automatic (original size, or proportional to the height respecting the ratio). default: 0

height: height in pixel for the standard size of the picture. Use 0 to indicate it should be automatic (original size, or proportional to the width respecting the ratio). default: 0

flipHorizontal: set to true if you want to flip the image horizontally default: false

flipVertical: set to true if you want to flip the image vertical default: false

trim: set to true if you want to remove the surrounding space (see here) default: false

fitIn: set to true if you want to shrink the image instead of auto-crop it (see here) default: false

manualCrop: If you want to manually crop the image to a certain position, set this property to an object {top: y1, left: x1, bottom: y2, right: x2}. Set to false for no manual cropping. default: false

horizontalAlign: see here default: 'center'

verticalAlign: see here default: 'middle'

smart: set this to false to disable the smart detection of focal points. See here for more details. default: true

filters: An object which keys correspond to the filter names as defined in the documentation, and values are either:

  • true when no argument is needed for the filter
  • a single value when the filter takes only one argument
  • an array of values corresponding to the parameters to be passed in the right order default: {}

Example:

const filters = {
	grayscake: true,
	background_color: 'blue',
	rgb: [20, 50, 60],
	blur: 7
}

Other Image Properties

id, className, style, alt, crossOrigin: are possible to send and apply to the image

Keywords

react

FAQs

Package last updated on 31 Mar 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.