SVG in WYSIWYG #553
-
I have an interactive SVG I need to put in a WYSIWYG field (or any field). Wondering if something else in Flynt is blocking it? Anyone have any ideas? This is the SVG I am working with: This is the function I have added to the /inc folder: `add_filter('wp_kses_allowed_html', 'acf_add_allowed_svg_tag', 10, 2);
}` |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
@shandyw In general, this behavior should not getting produced from Flynt. Flynt provides a helper function getContents inside its If the svg should be rendered inside the markup directly i would suggest to use a separate field for the svg file (for example an image field) and then use a filter inside functions.php file of your component to get the content of it: use Flynt\Utils\Asset;
add_filter('Flynt/addComponentData?name=YourComponent', function (array $data): array {
$svgFullpath = 'fullPathOfYourSvg'; // maybe get the path from the image field.
$data['rawSvg'] = Asset::getContents("{$svgFullpath}");
return $data;
}); After this We also use a similar approach for some premium components (List Social or Navigation Footer Columns), but there are the svg files part of the component itself. Hope this helps? |
Beta Was this translation helpful? Give feedback.
@shandyw In general, this behavior should not getting produced from Flynt. Flynt provides a helper function getContents inside its
Asset
class, which we often use for such kind of cases.If the svg should be rendered inside the markup directly i would suggest to use a separate field for the svg file (for example an image field) and then use a filter inside functions.php file of your component to get the content of it: