Jump to content

SVG Sanitizer


adrian
 Share

Recommended Posts

Sorry, I am not a developer and it has been years since I looked at PW last – so please excuse my ignorance. This is just for my personal website where I am the only user. I have no idea where to put this code. Which file? I’m trying to put these SVGs in my `basic-page` and `blog-post` templates. In the `basic-page` there is just `$content = $page->body;` (and then some navigation).

At least the `sth` field works, and I can upload the SVGs to it, and then place them in a page.

Link to comment
Share on other sites

@ClausWell, I can't guess where you would need the output of the SVG. If you need it just before the body content, it could look s.th. like this:

$content = "<div class='svg-container'>" . file_get_contents($page->image->filename) . "</div>";
$content .= $page->body;

Note the .= for appending to $content.

If you want the SVG to appear somewhere in the middle of the body content I'd recommend looking into the Hanna Code module.

If all you need is a single (or few) SVG in your page body, Hanna Code might also work without an extra SVG field, when you'd copy the SVG source directly in a tag (Haven't tested this). You could then place the tag within the body field like [[svg]]. The body field will the need to have the Hanna Code Text Formatter added as last element (in body Field Settings > Details > Text Formatters) to be able to output the tag.

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...