Problems, need help? Have a tip or advice? Post it here.
3 posts Page 1 of 1
Hi! I'm giving CouchCMS a try and overall it's been a smooth hence so far. Except that I can't get SVG to upload and display properly. If I add SVG to my site normally (outside of an editable region), they display without issue. I've read that the image uploader doesn't support SVG - which is a total bummer. The file uploader does upload the SVG imager but it displays as blank and then doesn't actually get inserted into the page.

I've added this to my globals page:
Code: Select all
<cms:editable
  name='my_logo'
  label='Upload Logo'
  desc='Upload the file here'
  type='file'
/>


And this to a header file in the snippets folder:
Code: Select all
<img src="<cms:show my_logo />"


Inspecting in the browser, nothing shows up in the image source.

Is there a step I missed or did incorrectly? Or is there a better way to add replaceable SVG?
Hi,

Using type 'file' editable region for SVG is the correct way in Couch.
Also, the code you posted seems to be fine to me.

So, let us try and debug the issue -
1. In the admin-panel, do you see the full URL of the uploaded SVG in the file region?
2. If yes, copy it and try pasting it in your browser's address bar; is the SVG being served as expected?
3. If yes, try outputting the 'file' region's content (which is the SVG's URL used above) on the front-end -
To do so, place the following in your template (close to where you'd like to display the SVG)
Code: Select all
<h1>SVG is: <cms:show my_logo /> </h1>

You should see the SVG's URL being outputted here.
If not, then make sure you are trying to use <cms:show my_logo /> in the correct context (e.g. page-view if the template is clonable).

If everything works, then there is no reason why outputting the same value as 'src' of <img> wouldn't show the SVG.

Hope this helps.
Thanks so much for the swift reply! I actually just figured it out. Since this was a "global" asset, I needed a reference to the global page.
Code: Select all
<img src="<cms:get_custom_field 'my_logo' masterpage='globals.php' />"

Now everything is displaying perfectly.

Should the SVG icon display in the file uploader though? Because it just displays as an empty square.
3 posts Page 1 of 1