germanyt / gulp-img-retina

add img attribute 'srcset' for retina
MIT License
3 stars 3 forks source link

Bails if the attributes are not in the correct order #2

Closed mattstratton closed 7 years ago

mattstratton commented 7 years ago

Due to using this in a static site generator, where I don't always have full control of the img tags, if a tag exists that doesn't start with <img src = "..." alt = "..." ...>, it bails because it doesn't like the second part of the index.

The error is

atal TypeError: Cannot read property '1' of null
    at Object.<anonymous> (/Users/mattstratton/Dropbox/src/github.com/devopsdays/devopsdays-theme/node_modules/gulp-img-retina/index.js:45:23)
    at initialize.exports.each (/Users/mattstratton/Dropbox/src/github.com/devopsdays/devopsdays-theme/node_modules/cheerio/lib/api/traversing.js:294:24)
    at DestroyableTransform._transform (/Users/mattstratton/Dropbox/src/github.com/devopsdays/devopsdays-theme/node_modules/gulp-img-retina/index.js:37:11)
    at DestroyableTransform.Transform._read (/Users/mattstratton/Dropbox/src/github.com/devopsdays/devopsdays-theme/node_modules/through2/node_modules/readable-stream/lib/_stream_transform.js:159:10)
    at DestroyableTransform.Readable.read (/Users/mattstratton/Dropbox/src/github.com/devopsdays/devopsdays-theme/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:365:10)
    at flow (/Users/mattstratton/Dropbox/src/github.com/devopsdays/devopsdays-theme/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:739:34)
    at DestroyableTransform.<anonymous> (/Users/mattstratton/Dropbox/src/github.com/devopsdays/devopsdays-theme/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:610:7)

I'll see if I can hack on this and submit a PR.

germanyt commented 7 years ago

This problem has nothing to do with the order. It like that src don't match for /^((?:(?:http|https):\/\/)?(?:.+))(\.(?:gif|png|jpg|jpeg|webp|svg))$/. Now you can update the modules at 0.0.4, try it.

mattstratton commented 7 years ago

This seems to be working now. Thanks!