docusaurus/packages/docusaurus-plugin-ideal-image
Joshua Chen 60960b471d
chore: upgrade dependencies, fix lint-staged not outputting formatted log (#7388)
* chore: upgrade dependencies, fix lint-staged not outputting formatted log

* fix

* fix lock...
2022-05-10 22:42:45 +08:00
..
src fix: fix a lot of declaration semantic errors (#7194) 2022-04-17 23:44:20 +08:00
.npmignore misc: convert all internal scripts to ESM (#6286) 2022-01-08 12:59:28 +08:00
copyUntypedFiles.mjs misc: convert all internal scripts to ESM (#6286) 2022-01-08 12:59:28 +08:00
package.json chore: upgrade dependencies, fix lint-staged not outputting formatted log (#7388) 2022-05-10 22:42:45 +08:00
README.md docs(v2): Add READMEs to v2 packages (#4034) 2021-01-14 17:16:26 +01:00
tsconfig.browser.json refactor(plugin-ideal-image): migrate package to TS (#5940) 2021-11-17 14:10:23 +01:00
tsconfig.json chore: remove baseUrl from tsconfig (#7258) 2022-04-28 22:03:25 +08:00
tsconfig.server.json refactor(plugin-ideal-image): migrate package to TS (#5940) 2021-11-17 14:10:23 +01: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