Giter VIP home page Giter VIP logo

gulp-html-lqip's Introduction

DEPRECATED: All plugins have been moved into the main repository.

See gulp-html-transform for usage

gulp-html-lqip

This is a plugin for gulp-html-transform

Adds Low Quality Image Placeholders using lqip to your html

Installing

Using npm

$ npm install --save gulp-html-lqip

Using yarn

$ yarn add gulp-html-lqip

Usage

gulpfile.js

const path = require('path')
const { transform } = require('gulp-html-transform')
const { lqip } = require('gulp-html-lqip')

gulp.task('html', () => {
  gulp.src('src/**/*.html')
  .pipe(transform(
    lqip({
      base: path.join(__dirname, 'src'),
      addStyles: true,
    })
  ))
  .pipe(gulp.dest('dist'))
})

If you want to add the styles manually you can import index.css from the package folder and remove addStyles.

Html in:

<img src="image.jpg">

Html out:

<div class="lqip" style="padding-top:50%;background-image:url(data:image/jpeg;base64,...">
  <img src="image.jpg" onload="this.parentElement.className='lqip'">
</div>

API

lqip({
  // Required:
  base: __dirname + '/src', // usually dirname plus something else, it's relative to where your files are 

  // Optional
  query: 'img[src]', // the query to find images. Might use a class like '.lqip-image'
  addStyles: boolean, // Whether you want to add a style-tag to your head. If not, you will need to import the styles manually. Defaults to false
})

gulp-html-lqip's People

Contributors

maistho avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.