# gulp_img_transform_to_picture

> Replace the to within HTML files, support Webp and Avif formats.

Latest version **3.2.0** (published 2024-03-22) · MIT license · 0 weekly downloads

## Install

```sh
npm install gulp_img_transform_to_picture
pnpm add gulp_img_transform_to_picture
yarn add gulp_img_transform_to_picture
bun add gulp_img_transform_to_picture
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.2.0 |
| Published | 2024-03-22 |
| First published | 2023-07-14 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 2 |
| Unpacked size | 8.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Blatisgense |
| Maintainers | blatisgense_frontend |
| Keywords | gulp, webp, html, avif, blatisgense, typescript |

## Links

- npm: https://www.npmjs.com/package/gulp_img_transform_to_picture
- Repository: https://github.com/blatisgense/gulp_img_transform_to_picture
- Homepage: https://github.com/blatisgense/gulp_img_transform_to_picture#readme
- Issues: https://github.com/blatisgense/gulp_img_transform_to_picture/issues
- npm.io page: https://npm.io/package/gulp_img_transform_to_picture

## Dependencies (2)

- [through2](https://npm.io/package/through2.md) ^3.0.1
- [plugin-error](https://npm.io/package/plugin-error.md) ^2.0.1

## Alternatives

- [@tsparticles/shape-image](https://npm.io/package/@tsparticles/shape-image.md) — 303.7K weekly downloads
- [@tsparticles/shape-line](https://npm.io/package/@tsparticles/shape-line.md) — 233.7K weekly downloads
- [stringify-attributes](https://npm.io/package/stringify-attributes.md) — 58.6K weekly downloads
- [mobile-drag-drop](https://npm.io/package/mobile-drag-drop.md) — 46.3K weekly downloads
- [@comunica/actor-rdf-parse-html](https://npm.io/package/@comunica/actor-rdf-parse-html.md) — 29.2K weekly downloads

## Recent versions

- 3.2.0 (latest) — 2024-03-22
- 3.1.0 — 2024-03-22
- 3.0.1 — 2024-03-20
- 2.2.1 — 2023-07-30
- 2.2.0 — 2023-07-26
- 2.1.1 — 2023-07-21
- 2.1.0 — 2023-07-21
- 2.0.2 — 2023-07-21
- 2.0.1 — 2023-07-21
- 2.0.0 — 2023-07-21
- 1.8.0 — 2023-07-18
- 1.7.0 — 2023-07-16
- 1.6.1 — 2023-07-15
- 1.6.0 — 2023-07-14
- 1.5.1 — 2023-07-14
- … 2 more at https://npm.io/package/gulp_img_transform_to_picture/versions

## README

# gulp_img_transform_to_picture
Replace the `<img>` to `<picture>` within HTML files, support Webp and Avif formats.
- **[Usage example](#Usage-example)**
- **[Options](#Options)**
- **[Last changes](#Last-changes)**
- **[Contacts](#Contacts)**
## Usage example
- Gulpfile: 
```js
import gulp from 'gulp';
import gulp_img_transform_to_picture from 'gulp_img_transform_to_picture';

const gulp_function = () => {
    return gulp.src("./src/**/*.html")
        .pipe(gulp_img_transform_to_picture(Config)) // recomend to use before minify
        .pipe(gulp.dest("./dest/"))
}
```
- Input:
```html
<img src="filename.jpg" ...any_attributes>
<img src="filename.jpg" ...any_attributes data-ignore>
```
- Output:
```html
<picture>
    <source srcset="filename.avif" type="image/avif">
    <source srcset="filename.webp" type="image/webp">
    <img src="filename.jpg" ...any_attributes>
</picture>
<img src="filename.jpg" ...any_attributes data-ignore>
```
## Options
### display_contents
Type: `boolean`<br>Default: `false`<br>Description: insert `display: contents;` as an inline style for \<picture>. **[Official documentation](https://developer.mozilla.org/en-US/docs/Web/CSS/display#contents)**


### extensions
Type:
```ts
type Extension = "avif" | "webp" | boolean;
interface Extensions<T> {
    [key: string]: T; // any custom formats
    png?: T;
    jpg?: T;
    jpeg?: T;
}
```
Default:
```ts
{
    png: "webp";
    jpg: true;
    jpeg: true;
}
```
Description:
Configure behavior for different extensions. `false` disable transformation,
`true` insert `<source>` for both Webp and Avif, `"avif"` or `"webp"` only specified one. 


### quotes
Type:`"single"` | `"double"`<br>Default:`"double"`<br>Description: Quotes type within HTML tags.


### ignore_attr
Type:`string`<br>Default:`data-ignore`<br>Description: Ignores and not transform `<img>` with this attribute.


### logger
Type:`boolean | "error" | "success"`<br>Default:`false`<br>Description: Logger outputs info about plugin's work
(errors and statistics).
`false` disable Logger, `true` logs both Errors and Statistics, `"error"` of `"stats"` only specified one.
## Last changes
**Patch 3.2.0:**
- Fix Config type issue.
- Add minification by Terser.
- Add warning if file's extension unsupported.
- Change Config.Quotes defining.
- Small optimizations.

**Patch 3.1.0:**
- Fix issues with default config values.
- Added ignore feature. Now able to ignore tags with special ignore attribute.
- Added _Logger_, outputs info about plugin's work (errors and statistics)

<br><br>You can see full changelogs and source code at **[GitHub repository](https://github.com/blatisgense/gulp_img_transform_to_picture)**
## Contacts:
If you notice any bug, or you want to suggest an idea, please contact me.
- **[Telegram](https://t.me/Blatisgense)**: @Blatisgense (best way)
- **[Discord](https://discordapp.com/users/559703556295360512)**: blatisgense
- **[Email](mailto:lavr.marudenko@gmail.com)**: lavr.marudenko@gmail.com

---
_Source: https://npm.io/package/gulp_img_transform_to_picture · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
