How can I use SVG for all graphics on my website?

Solved

How can I use SVG for all graphics on my website?

BirdhouseUSA
Shopify Partner
63 4 21

Hello, we have a lot of small graphics on our website and the client requested we use SVG for all of them.

I am not seeing this as an option in Shopify. Is there a way to do this that the customer can also manage (without going in to the code).

 

Thank you!

 

https://cast-elegance.myshopify.com/

castdev

Birdhouse Web Design
Accepted Solution (1)

Ninthony
Shopify Partner
2354 355 1050

This is an accepted solution.

Unfortunately, Shopify's image picker does not support SVGs. There is a possible work around, but it will require editing some code. 


If you want to give a client the ability to add an SVG through the customize editor, what you could do is use a text input instead of an image picker in the schema. You could upload the SVG via Settings > Files – and then in the text area you would type the name of the image including the extension. Lets just make a simple section that accepts a text input and would output the SVG on the page assuming the correct name and extension is typed into the image editor:

 

<div class="section-container">
<img src="{{ section.settings.svg_path | file_url }}">
</div>
{% schema %}
{
"name": "SVG Uploader",
"class": "svg-uploader",
"tag": "section",
"settings": [
{
"type": "header",
"content": "Desktop Settings"
},
{
"type": "text",
"id": "svg_path",
"label":"SVG Path"
}

],
"presets": [
{
"name": "SVG Uploader",
"category":"Image",
"settings": {
}
}
]

}
{% endschema %}


{% javascript %}
{% endjavascript %}

 

Then in the customize editor you'd just have to type the name of the file and the extension:

Ninthony_0-1625593378419.png

 

This would output your logo onto the page which you could then manipulate with CSS.

If my solution helped you, please like it and accept it as the solution!
If you'd like to make any edits to your store, please send me a personal message and we can discuss what you'd like to accomplish 😄

View solution in original post

Replies 3 (3)

Ninthony
Shopify Partner
2354 355 1050

This is an accepted solution.

Unfortunately, Shopify's image picker does not support SVGs. There is a possible work around, but it will require editing some code. 


If you want to give a client the ability to add an SVG through the customize editor, what you could do is use a text input instead of an image picker in the schema. You could upload the SVG via Settings > Files – and then in the text area you would type the name of the image including the extension. Lets just make a simple section that accepts a text input and would output the SVG on the page assuming the correct name and extension is typed into the image editor:

 

<div class="section-container">
<img src="{{ section.settings.svg_path | file_url }}">
</div>
{% schema %}
{
"name": "SVG Uploader",
"class": "svg-uploader",
"tag": "section",
"settings": [
{
"type": "header",
"content": "Desktop Settings"
},
{
"type": "text",
"id": "svg_path",
"label":"SVG Path"
}

],
"presets": [
{
"name": "SVG Uploader",
"category":"Image",
"settings": {
}
}
]

}
{% endschema %}


{% javascript %}
{% endjavascript %}

 

Then in the customize editor you'd just have to type the name of the file and the extension:

Ninthony_0-1625593378419.png

 

This would output your logo onto the page which you could then manipulate with CSS.

If my solution helped you, please like it and accept it as the solution!
If you'd like to make any edits to your store, please send me a personal message and we can discuss what you'd like to accomplish 😄

EugeneHarin
Shopify Partner
1 0 1

Starting from April 2023 this has become an official feature and is no longer an issue
https://eugeneharin.hashnode.dev/shopify-introduces-native-svg-support

Untitled.png

Ninthony
Shopify Partner
2354 355 1050

Thanks for the update @EugeneHarin , I missed the announcement and have still been dancing around this for months lol.

If my solution helped you, please like it and accept it as the solution!
If you'd like to make any edits to your store, please send me a personal message and we can discuss what you'd like to accomplish 😄