UNPKG

@wordpress/blocks

Version:
31 lines (28 loc) 906 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = imageCorrector; /** * This method check for copy pasted img elements to see if they don't have suspicious attributes. * * @param {Node} node The node to check. * * @return {void} */ function imageCorrector(node) { if (node.nodeName !== 'IMG') { return; } // For local files makes sure the path doesn't end with an invalid extension. // This scenario often happens with content from MS Word and similar text apps. // We still need to support local files pasted from the users Media library. if (node.src.startsWith('file:') && node.src.slice(-1) === '/') { node.setAttribute('src', ''); } // Remove trackers and hardly visible images. if (node.height === 1 || node.width === 1) { node.parentNode.removeChild(node); } } //# sourceMappingURL=image-corrector.native.js.map