Server IP : 162.213.251.212 / Your IP : 3.145.94.199 [ Web Server : LiteSpeed System : Linux business55.web-hosting.com 4.18.0-553.lve.el8.x86_64 #1 SMP Mon May 27 15:27:34 UTC 2024 x86_64 User : allssztx ( 535) PHP Version : 8.1.31 Disable Function : NONE Domains : 1 Domains MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/allssztx/public_html/easybuyer/node_modules/svgo/plugins/ |
Upload File : |
'use strict'; exports.type = 'perItem'; exports.active = false; exports.description = 'removes width and height in presence of viewBox (opposite to removeViewBox, disable it first)'; /** * Remove width/height attributes and add the viewBox attribute if it's missing * * @example * <svg width="100" height="50" /> * ↓ * <svg viewBox="0 0 100 50" /> * * @param {Object} item current iteration item * @return {Boolean} if true, with and height will be filtered out * * @author Benny Schudel */ exports.fn = function(item) { if (item.isElem('svg')) { if (item.hasAttr('viewBox')) { item.removeAttr('width'); item.removeAttr('height'); } else if ( item.hasAttr('width') && item.hasAttr('height') && !isNaN(Number(item.attr('width').value)) && !isNaN(Number(item.attr('height').value)) ) { item.addAttr({ name: 'viewBox', value: '0 0 ' + Number(item.attr('width').value) + ' ' + Number(item.attr('height').value), prefix: '', local: 'viewBox' }); item.removeAttr('width'); item.removeAttr('height'); } } };