Best Practice: SVG Wordpress like a Boss

There is currently an open issue for me (and another dev).
How have you solved it?

1 Like

I’ll put this here in case anyone else is ever looking

There is an awesome way to go about it.

Make a folder for svgs in resources resources/assets/icons
Making a Namespace for icons in view.php

    'namespaces' => [
        'icon' =>  get_theme_file_path().'/resources/assets/icons'
    ],

Save SVG in icons directory with the extension .blade.php

Bring in SVG into any blade template by using include('icon::somesvg')

credit is due to https://www.youtube.com/watch?v=P6XegfqED4o
<3

1 Like

@Log1x using https://github.com/Log1x/sage-svg with sage 10 and works great
when production, do svg-s need to be also in public folder (with mix.copyDirectory)? Asking because one client saw just string instead of actual svg or could that be some caching issue?