# posthtml-sugar-srcset
**Repository Path**: mirrors_posthtml/posthtml-sugar-srcset
## Basic Information
- **Project Name**: posthtml-sugar-srcset
- **Description**: This shortens the description of the value of srcset.
- **Primary Language**: Unknown
- **License**: MIT
- **Default Branch**: master
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 0
- **Forks**: 0
- **Created**: 2020-09-25
- **Last Updated**: 2025-10-05
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
# posthtml-sugar-srcset
[](https://badge.fury.io/js/posthtml-sugar-srcset)
[](https://travis-ci.org/posthtml/posthtml-sugar-srcset)
Sugar for srcset attributes of the image tag.
## Install
```
$ npm install --save-dev posthtml-sugar-srcset
```
## How it works
```html
```
Output:
```html
```
## Usage
``` js
const posthtml = require('posthtml');
const srcset = require('posthtml-sugar-srcset');
posthtml([srcset()])
.process(html)
.then(res => console.log(res.html));
```
## Options
#### resolution
Type: `Object`
#### resolution.src
Type: `boolean`
Default: `true`
If false, pixel density descriptor will not be converted.
#### resolution.srcset
Type: `boolean`
Default: `true`
If false, pixel density descriptor will not be converted.
##### resolution.suffix
Type: `string`
Default: `@[match]x`
Reference string.
If this pattern is included in src, it is based on the character excluding the pattern.
##### resolution.pixelRatio
Type: `Array`
Default: `[1, 2, 3, 4]`
src based filtering list.
##### resolution.skip1x
Type: `boolean`
Default: `true`
If srcset is 1x, omitted.
##### resolution.skip1xSuffix
Type: `boolean`
Default: `true`
If true, omitting the 1x word input of srcset.
##### resolution.srcReplace
Type: `number`
Default: `1`
Default value of src.
If -1, base string is used.
#### responsive
Type: `Object`
##### responsive.src
Type: `boolean`
Default: `true`
If false, width descriptor will not be converted.
##### responsive.srcset
Type: `boolean`
Default: `true`
If false, width descriptor will not be converted.
##### responsive.width
Type: `Array`
Default `[]`
src based filtering list.
Only be used if `responsive.src: true`.
ex)
```js
srcset({
responsive: {
src: true,
width: [320, 640]
}
})
```
##### responsive.suffix
Type: `string`
Default: `-[match]w`
Reference string.
If this pattern is included in src, it is based on the character excluding the pattern.
##### responsive.srcReplace
Type: `number`
Default: `-1`
Default value of src.
If -1, base string is used.
#### replace
Type: `Object`
Default: `{}`
Is the alias that can be used in sizes and media.
Valid only in the source tag with a picture tag to the parent.
ex)
``` js
replace({
defaultSizes: '50vw',
sp: '(max-width: 320px) 100vw',
pc: '320px'
large: '(max-width: 1600px)',
medium: '(max-width: 900px)'
})
```
Before
```html
```
After
```html
```
#### sourceSrc
Type: `boolean`
Default: `true`
If you true, to use the src attribute of the source tag.
After use, delete it.