🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more

super-image

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

super-image

React component that render `` with nicer interface

2.4.0
latest
Version published
Weekly downloads
5
-70.59%
Maintainers
6
Weekly downloads
 
Created

SuperImage

Greenkeeper badge Build Status devDependency Status peerDependency Status codecov

React component that render <img> with nicer interface

Install

$ npm install --save super-image

This package use Object.assign(), so you may need to polyfill via object.assign.

Usage

<SuperImage
  src="image.png"
  width="160"
  height="90"
  alt="super-image"
  fit="contain"
/>

Use <picture> element

Set sources property.

<SuperImage
  src="image.png"
  sources={[{
    srcSet : 'image.webp',
    type   : 'image/webp'
  }]}
  width="160"
  height="90"
  alt="super-image"
  fit="contain"
/>

Use object-fit fallback

Set fitFallback property true.

<SuperImage
  fitFallback
  src="image.png"
  width="160"
  height="90"
  alt="super-image"
  fit="contain"
/>

Config

PropertyTypeDescriptionDefault valueRequired
srcStringImage url-Yes
sourcesArraySets of <source> attributes: srcSet, sizes, media and type[]No
widthDOMStringImage width-No
heightDOMStringImage height-No
altStringAlternative text for <img>""No
roleStringWAI-ARIA for <img>-No
classNameStringclassName property for component""No
flexibleBooleanMake component fluidfalseNo
fitStringCSS object-fit property for <img> (contain or cover)-No
fitFallbackBooleanForce component to use background-imagefalseNo

License

MIT © FRESH!

FAQs

Package last updated on 15 Aug 2018

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