- This topic has 9 replies, 2 voices, and was last updated 4 years ago by Leo.
-
AuthorPosts
-
March 26, 2020 at 3:19 am #1210438feisar
I’m trying to add an inline SVG image as a href link (so it can be styled via CSS) to the Copyright section of my sites footer.
However, the SVG code is stripped out or, if entered as a data URI, displayed raw on the page.
Is there a recommended (and safe) way to do this?
(Using a link to an external SVG displays ok, but then can’t be styled via CSS).
Thanks for any tips.
March 26, 2020 at 9:49 am #1210975LeoStaffCustomer SupportHi there,
Any chance you can link us to the site in question?
You can edit the original topic and use the private URL field.
Let me know π
March 26, 2020 at 9:53 am #1210985feisarThanks, I’ve added the link to the private URL field.
It’s the “Site by” logo at the very bottom right of the page.
I was hoping to use the
fill: currentColor;
CSS as mentioned here, to allow the logo to adopt the color of the surrounding text, and then use CSS to change the fill colour on hover.March 26, 2020 at 5:27 pm #1211346LeoStaffCustomer SupportNot sure if fully understand.
Does that method work in regular page content?
The copyright box should take HTML just like the regular page content.
March 27, 2020 at 1:47 am #1211562feisarHere’s a reduced case example. If you add the following code into the regular page content, the SVG displays and inherits the colour of the parent, including hover colour changes.
<a href="#"><svg viewBox="0 0 23 23" height="20" width="20" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="2"><circle cx="11.25" cy="11.25" r="11.25" fill="currentColor"/></svg> Inherits link color with hover</a>
If you enter exactly the same code into Customiser > Layout > Footer > Copyright the SVG doesn’t display in the preview and the SVG code is stripped out when saving.
I’ve tried with the Safe SVG and SVG Support plugins but they make no difference.
EDIT: If I generate the copyright section using the ‘generate_copyright‘ function rather than the customiser, it works.
March 27, 2020 at 8:46 am #1212123LeoStaffCustomer SupportMust be something going on in the copyright field.
In this case
generate_copyright
would be the solution.Glad you were able to find an alternative solution!
March 27, 2020 at 8:50 am #1212128feisarThanks. It would be useful/easier if I could just use the Copyright field of the Customizer.
Do you think this is a bug, and if so, is it within GeneratePress (and potentially could be fixed) or within core WordPress functionality?
March 27, 2020 at 8:54 am #1212135LeoStaffCustomer SupportI believe that would be a WordPress functionality issue but we will definitely take a closer look.
Thanks π
March 27, 2020 at 9:11 am #1212175feisarThank you.
March 27, 2020 at 11:26 am #1212289LeoStaffCustomer SupportNo problem π
-
AuthorPosts
- You must be logged in to reply to this topic.