Home › Forums › Bug Reports › Register block type SVG icon not displayed › Reply To: Register block type SVG icon not displayed
Just a small update, the acf-block-icon
plugin is not actually working for me.
I did a little digging into the ACF code and it looks like a string starting with <svg
is being detected, but only for the icon
property and not if you’ve set the icon via icon['src']
. I was setting my icon like this because I want to have a custom foreground color:
acf_register_block_type( array(
// ...
'icon' => array(
'foreground' => '#7bb12d',
'src' => '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M0,0H24V24H0Z" fill="none"/><polygon points="20 18 4 18 4 20 20 20 20 18"/><path d="M22,3H2A1,1,0,0,0,1,4V15a1,1,0,0,0,1,1H22a1,1,0,0,0,1-1V4A1,1,0,0,0,22,3ZM21,5V9.92l-3.38-2.7a1,1,0,0,0-1.24,0L12,10.74,8.6,8.2a1,1,0,0,0-1.15,0L3,11.13V5ZM3,14v-.46l5-3.32L11.4,12.8a1,1,0,0,0,1.22,0L17,9.28l4,3.2V14Z"/></svg>',
),
I’m looking to see if I can add a filter via JS on blocks.registerBlockType
to handle the icon with foreground color for the time being.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.