WP Manifestindependent plugin directory
manifest / media / wp-svg-upload

SVG Upload

Adds full SVG media support to WordPress.

★ 2stars
383composer installs
v1.0.2latest · 10 years ago

Install

Download source zip No release zip yet

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/digimix/wp-svg-upload/archive/refs/heads/master.zip

On Packagist as digimix/wp-svg-upload:

composer require digimix/wp-svg-upload
No built-in updater. New versions won't appear under Dashboard → Updates. Install new releases yourself, or let Git Updater track the repository.

Installation Instructions

Install with Composer composer require digimix/wp-svg-upload

Install manually

  1. Clone or copy the files into your WordPress plugins directory
  2. Activate the plugin from the dashboard or using WP CLI

Once the plugin is activated, you're good to go. Your WordPress media library will support uploading SVG files.

Logic Breakdown

    1. We need the whole page, but only if we are in the backend (hence admin_init hook)
    1. We would like to grab all output (ob_start within admin_init as nothing should echo before that, we should not interfere with things that do)
    1. We want to grab the content on shutdown, concatenate all output buffers, then filter
    1. Search for placeholders which should exist and replace the text
  • Downsides
    1. Not permanent fix (for perma fix WP core would need to be editable or native filtering added)
    1. A bit resource munchy (it's locked to the admin side, so IMHO who cares)
    1. This is just to get SVG into WP core... Luckily the find replace is that simple in /wp-includes/media-template.php (Patch it Mullweng & Co!)

Changes...

  • Re-factored function declaration and calls to make compatible with lesser PHP versions, despite believing anyone using such versions is dangerous
  • Added param for mime-types to filter_mimes function
  • Moved into a namespace and class to make the whole thing less hack-and-slash
  • Updated to use short-array syntax (Breaking change update your PHP or don't use)
  • Deleted some dead code I never noticed before

Credits

Releases

3 releases.

Tag
Published
v1.0.2 latest
May 27, 2016 10 years ago
May 27, 2016 10 years ago
May 27, 2016 10 years ago

These releases are tags only. The author does not attach a packaged zip, so there are no download counts to report.