imgix-srcset
TypeScript icon, indicating that this package has built-in type declarations

1.1.0 • Public • Published

Imgix SrSet Generator

NPM npm bundle size License

A dead simple utility to generate responsive srcsets from an Imgix compatible source URL

Usage

Install via npm (or yarn etc)

npm i imgix-srcset

Import into your project and generate a srcset for any image you need, from an Imgix compatbile URL

Plain JS

import { srcset } from 'imgix-srcset';

const img = document.createElement('img');
img.src = '...';
img.srcset = srcset('...');

React

import { srcset } from 'imgix-srcset';

function ReactLazyImgix({ src }) {
  return <img src={src} srcset={srcset(src)} loading="lazy" />;
}

Imgix Options

By default existing parameters are stripped from the src Imgix image, you can specify any Imgix propreties you want in the srcset function

srcset('...', {
  fit: 'crop',
  ar: '16:9'
});

Readme

Keywords

none

Package Sidebar

Install

npm i imgix-srcset

Weekly Downloads

2

Version

1.1.0

License

MIT

Unpacked Size

4.72 kB

Total Files

6

Last publish

Collaborators

  • madeleineostoja