diff --git a/.svgo.yml b/.svgo.yml index 9cccbb2e..9a138406 100644 --- a/.svgo.yml +++ b/.svgo.yml @@ -32,6 +32,10 @@ plugins: active: true type: perItem + - name: removeRasterImages + active: false + type: perItem + - name: cleanupNumericValues active: true type: perItem diff --git a/plugins/removeRasterImages.js b/plugins/removeRasterImages.js new file mode 100644 index 00000000..b730b3a1 --- /dev/null +++ b/plugins/removeRasterImages.js @@ -0,0 +1,23 @@ +'use strict'; + +/** + * Remove raster images references in . + * + * @see https://bugs.webkit.org/show_bug.cgi?id=63548 + * + * @param {Object} item current iteration item + * @return {Boolean} if false, item will be filtered out + * + * @author Kir Belevich + */ +exports.removeRasterImages = function(item) { + + if ( + item.isElem('image') && + item.hasAttr('xlink:href') && + /(\.|image\/)(jpg|png)/.test(item.attr('xlink:href').value) + ) { + return false; + } + +}; diff --git a/test/plugins/removeRasterImages.01.orig.svg b/test/plugins/removeRasterImages.01.orig.svg new file mode 100644 index 00000000..a16c6a9a --- /dev/null +++ b/test/plugins/removeRasterImages.01.orig.svg @@ -0,0 +1,7 @@ + + + + + + + diff --git a/test/plugins/removeRasterImages.01.should.svg b/test/plugins/removeRasterImages.01.should.svg new file mode 100644 index 00000000..1bc122a8 --- /dev/null +++ b/test/plugins/removeRasterImages.01.should.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/test/plugins/removeRasterImages.02.orig.svg b/test/plugins/removeRasterImages.02.orig.svg new file mode 100644 index 00000000..b896b5af --- /dev/null +++ b/test/plugins/removeRasterImages.02.orig.svg @@ -0,0 +1,7 @@ + + + + + + + diff --git a/test/plugins/removeRasterImages.02.should.svg b/test/plugins/removeRasterImages.02.should.svg new file mode 100644 index 00000000..c6fc3f15 --- /dev/null +++ b/test/plugins/removeRasterImages.02.should.svg @@ -0,0 +1,5 @@ + + + + +