New Landing How can we help? Atelier No svg icons available to use.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Posted in: Atelier
  • #315672
    mariatrier
    Member
    Post count: 163

    Hi there,

    How to get or upload available SVG icons? I tried to upload via the media upload, but got an error saying I could not upload .svg files.

    Best regards,
    Maria

    Attachments:
    You must be logged in to view attached files.
    #315896
    David Martin – Support
    Moderator
    Post count: 20834

    Within your child theme functions.php file, paste this:

    	/* ADD PAGE BUILDER SVG ICONS
    	================================================== */
    	if ( !function_exists( 'spb_child_theme_svg_icons' ) ) {
            function spb_child_theme_svg_icons( $svg_icons ) {
    
            	if ( !$svg_icons ) {
            		$svg_icons = array();
            	}
    
                // Check if we can access files
                if ( !function_exists('glob') ) {
                    return $svg_icons;
                }
    
                // Path to directory to scan
                $folder = '/swift-builder-icons/svg/';
                $directory = get_stylesheet_directory() . $folder;
                $uri = get_stylesheet_directory_uri() . $folder;
    
                // Get all svg files
                $svgs = glob($directory . "*.svg");
    
                // If no files, return
                if ( empty($svgs) ) {
                    return;
                }
    
                // Add each icon to array
                foreach($svgs as $svg) {
                    $svg = basename($svg);
                    $key = $uri . $svg;
                    if ( !array_key_exists( $key, $svg_icons ) ) {
                        $svg_icons[ $key ] = $svg;
                    }
                }
    
                // Return array
                return $svg_icons; 
            }
            add_filter( 'spb_svg_icons_list', 'spb_child_theme_svg_icons' );
        }

    Add your .SVG files to the child theme folder /swift-builder-icons/svg/.

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in and have valid license to reply to this topic.

License required for one of the following items
Login and Registration Log in · Register