10up / safe-svg

Enable SVG uploads and sanitize them to stop XML/SVG vulnerabilities in your WordPress website.
https://wordpress.org/plugins/safe-svg/
GNU General Public License v2.0
272 stars 31 forks source link

Disable SVG optimization by default #145

Closed dkotter closed 1 year ago

dkotter commented 1 year ago

Description of the Change

In #79, we added SVG optimization using the SVGO library. This optimization is enabled by default and the only way to turn it off was through a filter. I had some concerns with this feature (around performance and potential issues with stripping params we may want to keep) and so in order to not delay a 2.2.0 release any longer, talked to @jeffpaul and decided that we would keep this feature in place but we would change this to be disabled by default.

A new filter has been added (safe_svg_optimizer_enabled) that returns false by default. Users that want to try out this new optimization feature will have to hook into that filter and return true:

add_filter( 'safe_svg_optimizer_enabled', '__return_true' );

This gives people the opportunity to test this out and decide whether they want this extra optimization or not (and doesn't impact sites that don't care about this). If enough people use and like this feature, in the future we can look to either enable this by default or add an admin setting to turn this on/off.

How to test the Change

Follow the steps outlined in #79, once you add the line of code above. Without that line in place, ensure optimization doesn't happen and everything works as expected.

Changelog Entry

Changed - Don't run SVGO optimization by default and instead make this an opt-in feature.

Credits

Props @dkotter, @jeffpaul

Checklist: