docusaurus/packages/docusaurus-plugin-ideal-image
Sébastien Lorber 8aa6ef47e4
feat(v2): configureWebpack merge strategy + use file-loader for common asset types (#2994)
* Add some default asset loaders
Add webpack merge strategy feature to enable plugins to prepend some webpack configuration (like the ideal image plugin that should override the default image loader)

* Add documentation for using assets from markdown

* add path prefix for webpack file loader

* renaming

* document Merge strategies

* rename mergeStrategies -> mergeStrategy
2020-07-01 19:06:02 +02:00
..
src feat(v2): configureWebpack merge strategy + use file-loader for common asset types (#2994) 2020-07-01 19:06:02 +02:00
.npmignore fix(v2): fix plugin-ideal-image breaking website (exports not defined) (#2074) 2019-12-01 21:59:02 +07:00
copyUntypedFiles.js chore: yearless copyright headers for source code (#2320) 2020-02-25 23:12:28 +08:00
package.json chore(v2): refactor scripts + add theme-classic watchmode (#2998) 2020-07-01 18:30:44 +02:00
README.md misc: add command to run prettier on docs (#2102) 2019-12-07 21:56:30 -08:00
tsconfig.json fix(v2): fix plugin-ideal-image breaking website (exports not defined) (#2074) 2019-12-01 21:59:02 +07: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