[Resolved] SVG Sprite with Generateblocks icon function

Home Forums Support [Resolved] SVG Sprite with Generateblocks icon function

Home Forums Support SVG Sprite with Generateblocks icon function

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #1458229
    Alexander

    Hello GP-Team,

    I am using Generatepress 3.0 beta2 and the latest GP Premium RC with Generateblocks on a site that I am currently working on.
    Previously I was using an SVG sprite sheet for a handful of icons that are being used throughout the site like so:

    <svg class="mysvgicon"> <use xlink:href="/wp-content/themes/mytheme/svg/si-sprite.svg#si-entypo-brush"></use></svg>

    Now I am trying to do the same with the icon option in Generateblocks but my code seems to fall victim to sanitization.

    What would be a good way of getting this to work?
    Also, do you recommend using the Generateblocks Headline block for paragraphs over the default WordPress paragraphs?

    Thanks in advance!

    #1458339
    David
    Staff
    Customer Support

    Hi there,

    The GB Icon field will only accept an inline SVG – you cannot use xlink:href at this time. That maybe something we review in the future but that method doesn’t have the best browser support….

    Paragraphs – no we recommend you use a Paragraph block. Reserve using the Headline Block when you need to create a different styled element to those the Customizer body/heading typography provides.

    #1458356
    Alexander

    Hello David,

    that is too bad. It would be great if this could be supported in a future version.

    I noticed that xlink is being depreciated and the recommended way of linking is now plain href.
    Browser support seems OK with the exception of IE naturally but can be worked around with something like https://github.com/jonathantneal/svg4everybody

    I believe that a saw a post by Tom in the past with some code that lets you bypass the sanitization (could not find it again via search now). Since I am the only person that will be working on/having publishing rights on the site, do you think this would be a feasible option?

    #1458655
    David
    Staff
    Customer Support

    Theres this article which covers the WP sanitization:

    https://docs.generateblocks.com/article/fix-svg-icons-not-saving/

    Not aware of anything that excludes DomPurify from the code.
    Ill pass this on to Tom.

    #1458825
    Tom
    Lead Developer
    Lead Developer

    There is no way around DOMPurify at this time. Not sure if we’ll work that in, but it’s worth looking to see if we can allow this sort of implementation safely.

    #1459513
    Alexander

    That would be great. I do think that having a cache-able spritesheet does have benefits and support for it seems quite good with some exceptions.

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.