Skip to content

SVG in WYSIWYG #553

Answered by timohubois
shandyw asked this question in Q&A
Apr 30, 2024 · 1 comments · 4 replies
Discussion options

You must be logged in to vote

@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:

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;
});

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@shandyw
Comment options

@aaronmeder
Comment options

@kunsang
Comment options

@shandyw
Comment options

Answer selected by shandyw
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants