docusaurus/packages/docusaurus-plugin-ideal-image
Dongwoo Gim 104733914a refactor(v2): convert @docusaurus/plugin-ideal-image to TypeScript (#2011)
* refactor @docusaurus/plugin-ideal-image
refactor @docusaurus/plugin-ideal-image

* Update react-ideal-image.d.ts

* Update types.ts

* Update IdealImage.tsx

* Update package.json
2019-11-30 16:09:26 -08:00
..
@types refactor(v2): convert @docusaurus/plugin-ideal-image to TypeScript (#2011) 2019-11-30 16:09:26 -08:00
src refactor(v2): convert @docusaurus/plugin-ideal-image to TypeScript (#2011) 2019-11-30 16:09:26 -08:00
package.json refactor(v2): convert @docusaurus/plugin-ideal-image to TypeScript (#2011) 2019-11-30 16:09:26 -08:00
README.md feat(v2): @docusaurus/plugin-ideal-image (#1665) 2019-07-17 21:53:40 +08:00
tsconfig.json refactor(v2): convert @docusaurus/plugin-ideal-image to TypeScript (#2011) 2019-11-30 16:09:26 -08:00

@docusaurus/plugin-ideal-image

Docusaurus Plugin to generate an almost ideal image (responsive, lazy-loading, and low quality placeholder)

Installation

yarn add @docusaurus/plugin-ideal-image

Modify your docusaurus.config.js

module.exports = {
  ...
+ plugins: ['@docusaurus/plugin-ideal-image'],
  ...
}

Usage

Support png, gif and jpg only

import Image from '@theme/IdealImage';
import thumbnail from './path/to/img.png';

// your react code
<Image img={thumbnail} />

// or
<Image img={require('./path/to/img.png')} />

Options

Option Type Default Description
name string ideal-img/[name].[hash:hex:7].[width].[ext] Filename template for output files.
sizes array original size Specify all widths you want to use; if a specified size exceeds the original image's width, the latter will be used (i.e. images won't be scaled up). You may also declare a default sizes array in the loader options in your webpack.config.js.
size integer original size Specify one width you want to use; if the specified size exceeds the original image's width, the latter will be used (i.e. images won't be scaled up)
min integer As an alternative to manually specifying sizes, you can specify min, max and steps, and the sizes will be generated for you.
max integer See min above
steps integer 4 Configure the number of images generated between min and max (inclusive)
quality integer 85 JPEG compression quality