1.0.0 • Published 3 years ago

@technically/img-src-placeholder v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

img-src-placeholder

Micro library to generate data-uri placeholder images of a given size.

Features

  • Blazing fast
  • Zero dependencies
  • Ultra-small: less than 1KB (minified)
  • Works in browser
  • Works in server-side node
  • Typescript type definitions

Usage

Plain JS:

import { placeholder } from '@technically/img-src-placeholder';

document.querySelectorAll('img').forEach(function (img) {
  img.src = placeholder(100, 100); // placeholder returns a data-uri string ready-to-use as a `src` attribute. 
});

React:

import { placeholder } from '@technically/img-src-placeholder';

interface Props {
    width: number;
    height: number;
}

export function ImagePlaceholder({ width, height }: Props) {
  return <img src={placeholder(width, height)} />;
}

Credits

Created with ❤️ by Ivan Voskoboinyk 🇺🇦

1.0.0

3 years ago

0.0.6

3 years ago

0.0.5

3 years ago

0.0.4

3 years ago

0.0.3

3 years ago

0.0.1

3 years ago

0.0.0

3 years ago