๋ฉ”์ธ ์ปจํ…์ธ ๋กœ ์ด๋™
Version: 2.0.0-beta.16 ๐Ÿšง

๐Ÿ“ฆ plugin-ideal-image

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

info

By default, the plugin is inactive in development so you could always view full-scale images. If you want to debug the ideal image behavior, you could set the disableInDev option to false.

์„ค์น˜โ€‹

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

์‚ฌ์šฉ๋ฒ•โ€‹

ํ•ด๋‹น ํ”Œ๋Ÿฌ๊ทธ์ธ์€ PNG, GIF, JPG ํฌ๋งท๋งŒ ์ง€์›ํ•ฉ๋‹ˆ๋‹ค.

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

// ๋ฆฌ์•กํŠธ ์ฝ”๋“œ
<Image img={thumbnail} />

// ๋˜๋Š” ์•„๋ž˜์™€ ๊ฐ™์€ ์ฝ”๋“œ
<Image img={require('./path/to/img.png')} />

์„ค์ •โ€‹

์„ค์ •ํ•  ์ˆ˜ ์žˆ๋Š” ํ•„๋“œ

OptionTypeDefaultDescription
namestringideal-img/[name].[hash:hex:7].[width].[ext]Filename template for output files.
sizesnumber[]original sizeSpecify all widths you want to use. ์„ค์ •ํ•œ ํฌ๊ธฐ๊ฐ€ ์›๋ณธ ์ด๋ฏธ์ง€ ๋„ˆ๋น„๋ณด๋‹ค ํฌ๋‹ค๋ฉด ๋‹ค์Œ์— ์„ค์ •ํ•œ ์ด๋ฏธ์ง€ ํฌ๊ธฐ๋ฅผ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค(์ด๋ฏธ์ง€ ํฌ๊ธฐ๋ฅผ ํฌ๊ฒŒ ๋งŒ๋“ค์ง€๋Š” ์•Š์Šต๋‹ˆ๋‹ค).
sizenumberoriginal sizeSpecify 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)
minnumberAs an alternative to manually specifying sizes, you can specify min, max and steps, and the sizes will be generated for you.
maxnumberSee min above
stepsnumber4Configure the number of images generated between min and max (inclusive)
qualitynumber85JPEG compression quality
disableInDevbooleantrueYou can test ideal image behavior in dev mode by setting this to false. Tip: use network throttling in your browser to simulate slow networks.

์„ค์ • ์˜ˆ์‹œโ€‹

Here's an example configuration:

docusaurus.config.js
module.exports = {
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,
},
],
],
};