Replace the "src" attribute of <img> tags with specific path in HTML files.
It is very easy to replace original "src" with a CDN "src".
Installation
Install package with NPM and add it to your development dependencies:
npm install --save-dev gulp-replace-image-src
Usage
var rep = ;var gulp = ; gulp;
The original HTML is like:
After replaced, it should be like:
The plugin only keeps the original file name in the new path.
If you want to keep origin "src", then you can make keepOrigin
true
.
var rep = ;var gulp = ; gulp;
Then you will see the below HTML:
If the "src" starts with "http:|ftp:|https:|//", then it will NOT be replaced.
API
replace(options)
Options, Type: Object
.
options.prependSrc
Type:String
Default: /
Prepend the path string to every "src" attribute of "img" tag.
options.keepOrigin
Type:Boolean
Default:false
If the value is true
, then the new "src" is prepended to the origin "src".