We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent cc7079e commit b31efc6Copy full SHA for b31efc6
1 file changed
lib/index.js
@@ -64,10 +64,18 @@ function getPicture (imgNode, options) {
64
imgNode.skip = true
65
66
var src = imgNode.attrs.src
67
- if (options.replaceExtension) {
68
- src = removeExtension(src)
69
- }
70
- src += '.webp'
+ var srcset = (imgNode.attrs.srcset || '')
+ .split(',')
+ .concat(src)
+ .filter(Boolean)
71
+ .map(value => {
72
+ value = value.trim().split(/\s/)
73
+ var path = options.replaceExtension ? removeExtension(value[0]) : value[0]
74
+ var size = value[1]
75
+
76
+ return [path + '.webp', size].filter(Boolean).join(' ')
77
+ })
78
+ .join(', ')
79
80
return {
81
tag: 'picture',
@@ -76,7 +84,7 @@ function getPicture (imgNode, options) {
84
tag: 'source',
85
attrs: {
86
type: 'image/webp',
- srcset: src
87
+ srcset
88
}
89
},
82
90
imgNode
0 commit comments