Add SVG Upload Support to Beaver Builder

By default, WordPress blocks SVG uploads. Beaver Builder also blocks SVG uploads withing the builder, but strangely it uses it’s own block list which it only applies to uploads.

This means that you can enable SVG uploads within WordPress, upload an SVG file to the media library, and then make use of the file in Beaver Builder. However, you can’t simply upload the file from withing Beaver Builder.

If you would like to see Beaver Builder follow the WordPress allowed upload settings, please vote for this feature request by giving it a thumbs up: https://github.com/beaverbuilder/feature-requests/issues/58

Until then, we can use the following code to modify Beaver Builder’s allowed upload extension list to include SVG:

/**
 * Allow SVG uploads in Beaver Builder
 * 
 * Modifies the Beaver Builder file upload filter to allow SVG files.
 */
function prfx_bb_add_svg_support($regex) {
    $regex = array(
            'photo' => '#(jpe?g|png|gif|bmp|tiff?|svg)#i',
        );
    return $regex;
}
add_filter( 'fl_module_upload_regex', 'prfx_bb_add_svg_support');

This code can be placed in a plugin or in the functions.php file of the currently active theme.

Posted in

Leave a Comment

Your email address will not be published.