Snippets Collections
/**

 * Allow SVG uploads for administrator users.

 *

 * @param array $upload_mimes Allowed mime types.

 *

 * @return mixed

 */

add_filter(

    'upload_mimes',

    function ( $upload_mimes ) {

        // By default, only administrator users are allowed to add SVGs.

        // To enable more user types edit or comment the lines below but beware of

        // the security risks if you allow any user to upload SVG files.

        if ( ! current_user_can( 'administrator' ) ) {

            return $upload_mimes;

        }

​

        $upload_mimes['svg']  = 'image/svg+xml';

        $upload_mimes['svgz'] = 'image/svg+xml';

​

        return $upload_mimes;
star

Fri Feb 16 2024 11:48:23 GMT+0000 (Coordinated Universal Time)

#undefined #svg #allow-svg

Save snippets that work with our extensions

Available in the Chrome Web Store Get Firefox Add-on Get VS Code extension