Install
This is the repository archive. It installs, but the folder name will carry the branch suffix and updates will not flow.
Install straight from GitHub with WP-CLI:
wp plugin install https://github.com/inventivo/add-svg-support-for-media-uploader-inventivo/archive/refs/heads/master.zipWordPress plugin for controlled SVG uploads. Version 2.0.0 allows SVG files only for users with the unfiltered_html capability and sanitizes regular media-library, REST API and sideload uploads before storage.
SVG uploads through wp_upload_bits() are rejected before that function writes the file to its public destination. This intentionally includes the XML-RPC methods wp.uploadFile and mw_newMediaObject as well as SVG files handled by the WXR importer.
The attachment backstop remains active for unexpected paths that register an SVG attachment. Invalid SVG files and uploads without an available sanitizer are rejected. If a stored file cannot be cleaned, its attachment record and file are removed.
Requirements
- PHP 7.4 or newer
- WordPress 5.1 or newer, tested through WordPress 7.1
- Composer
- PHP extensions
domandlibxml
Installation
Install the package and its dependencies through the Composer setup of the WordPress project. For a standalone checkout, run:
composer install --no-dev
Then activate the plugin in WordPress.
Security behavior
- SVG is added to WordPress' allowed MIME types only for users with
unfiltered_html. - SVG is removed from the allowed MIME types while
wp_upload_bits()is running. XML-RPC and WXR imports therefore reject SVG files. enshrined/svg-sanitizecleans normal uploads before storage and checks every newly registered SVG attachment again when needed.- Safe internal CSS remains intact, including Illustrator `