/gulp-lqip-base64

Parses HTML files to find <img> tags and adds an attribute to them which contains their Base64 representation

Primary LanguageJavaScriptMIT LicenseMIT

gulp-lqip-base64

Parses HTML files to find <img> tags and adds an attribute to them which contains their Base64 representation.

npm (scoped) JavaScript Style Guide Travis (.com) David License

Demo

https://exuanbo.github.io/gulp-lqip-base64/

Install

npm install --save-dev gulp-lqip-base64

Usage

const { task, src, dest } = require('gulp')
const lqipBase64 = require('gulp-lqip-base64')

task('default', () => {
  return src('**/*.html', { base: '.' })
    .pipe(lqipBase64({ attribute: 'srcset' }))
    .pipe(dest('.'))
})

or you can

import lqipBase64 from 'gulp-lqip-base64'

Supported image types

Currently ['jpeg', 'jpg', 'png', 'bmp', 'tiff', 'gif'] are supported.

Options

Type: Object

srcAttr

  • Type: String
  • Default: src

Attribute which contain the image path.

attribute

  • Type: String
  • Default: data-src

Attribute which will contain the Base64 representation of the image.

Acknowledgement

Thanks gulp-image-lqip for the inspiration.

License

MIT

Donate

Buy Me A Coffee