Skip to content

Commit

Permalink
plugins/removeRasterImages: remove raster images references in <image…
Browse files Browse the repository at this point in the history
…> (disabled by default) (close #98)
  • Loading branch information
deepsweet committed Feb 13, 2013
1 parent 0ee129b commit 7ddc8eb
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .svgo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ plugins:
active: true
type: perItem

- name: removeRasterImages
active: false
type: perItem

- name: cleanupNumericValues
active: true
type: perItem
Expand Down
23 changes: 23 additions & 0 deletions plugins/removeRasterImages.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
'use strict';

/**
* Remove raster images references in <image>.
*
* @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;
}

};
7 changes: 7 additions & 0 deletions test/plugins/removeRasterImages.01.orig.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions test/plugins/removeRasterImages.01.should.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions test/plugins/removeRasterImages.02.orig.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions test/plugins/removeRasterImages.02.should.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 7ddc8eb

Please sign in to comment.