From 6deb77715bd2d5c18e920f6ba91f571070ec14df Mon Sep 17 00:00:00 2001 From: Eric Jinks Date: Wed, 6 Dec 2017 15:51:34 +1000 Subject: [PATCH] Ignore svg for src / srcset --- src/util/getImageUrl.js | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/util/getImageUrl.js b/src/util/getImageUrl.js index 6c96a3e..f6b50e0 100644 --- a/src/util/getImageUrl.js +++ b/src/util/getImageUrl.js @@ -3,10 +3,7 @@ const outputDir = '/images/uploads/' const resizedDir = '/images/uploads/resized/' const getImageSrcset = path => { - if (path.indexOf('http') >= 0) { - // Cannot get srcset for external image - return - } + if (path.match(/^http/) || path.match(/svg$/)) return null const filename = path.split('.').shift() const extname = path.split('.').pop() const pathname = encodeURI(filename.replace(outputDir, resizedDir)) @@ -18,7 +15,7 @@ const getImageSrcset = path => { } const getImageSrc = (path, sizeRequested) => { - if (path.indexOf('http') >= 0) return path + if (path.match(/^http/) || path.match(/svg$/)) return path sizeRequested = parseInt(sizeRequested, 10) let size if (sizeRequested) {