Skip to main content
Docusaurus

Search documentation

Type to search this documentation.

On this pageOverview

πŸ“¦ plugin-ideal-image

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

npm2yarn
npm install --save @docusaurus/plugin-ideal-image

This plugin supports the PNG and JPG formats only.

JSX
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')} />

Accepted fields:

mdx-code-block
<APITable>
Option Type Default Description
name string ideal-img/[name].[hash:hex:7].[width].[ext] Filename template for output files.
sizes number[] 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).
size number 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 number As an alternative to manually specifying sizes, you can specify min, max and steps, and the sizes will be generated for you.
max number See min above
steps number 4 Configure the number of images generated between min and max (inclusive)
quality number 85 JPEG compression quality
disableInDev boolean true You can test ideal image behavior in dev mode by setting this to false. Tip: use network throttling in your browser to simulate slow networks.
mdx-code-block
</APITable>

Here's an example configuration:

docusaurus.config.js
export default {  plugins: [    [      '@docusaurus/plugin-ideal-image',      {        quality: 70,        max: 1030, // max resized image's size.        min: 640, // min resized image's size. if original is lower, use that size.        steps: 2, // the max number of images generated between min and max (inclusive)        disableInDev: false,      },    ],  ],};
Suggest an edit

Propose a replacement for this page. The site team reviews it before applying any changes.

Export
Documentation menu