Last active
August 29, 2015 14:25
-
-
Save mpr0xy/6e4c41424f389e116139 to your computer and use it in GitHub Desktop.
mp-gulp-img-src
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var through = require('through2'); | |
module.exports = function() { | |
return through.obj(function (file, enc, cb) { | |
if (file.isNull()) { | |
cb(null, file); | |
return; | |
} | |
if (file.isStream()) { | |
cb(new gutil.PluginError('gulp-mp-upai-upload', 'Streaming not supported')); | |
return; | |
} | |
var fileContext = file.contents.toString(); | |
var imgReg_g = /<img.+src=('|")(\S+)('|")\s/gi; | |
var imgReg = /<img.+src=('|")(\S+)('|")\s/i; | |
var foundImg_array = fileContext.match(imgReg_g); | |
foundImg_array.forEach(function(item, index) { | |
var results = foundImg_array[index].match(imgReg); | |
if (results) { | |
console.log(results[2]); | |
} | |
}) | |
// console.log(foundImg_array); | |
cb(); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment