acf-svg-icon
acf-svg-icon copied to clipboard
svg files fixed for theme path
Hi 7studio, great work!
One thing I noticed is that it assumes that the svg icons are in (a subfolder of) the theme folder. I was trying to add them packaged as a plugin but the str_replace() on the load_field() callback was preventing my icons from displaying.
I added two extra filters as a workaround to be able to set both search and replace parameters, now my svg can be located in that plugin-folder too.
Hi @badabingbreda,
You are totally right and it's a stupid restriction. But it was out of my scope/need when I created the plugin :sweat_smile:
The problem comes from the line 202 in fields/class-swp-acf-svg-icon-v5.php
.
We can resolve the problem in two steps :
- Replace the current wrong line/behaviour by:
$field['file']['url'] = str_replace( get_home_path(), home_url( '/' ), $field['file']['path'] );
. This change should solve your problem. - Offer three filters like
acf/fields/svg_icon/file_path
for the file URL (e.g.:acf/fields/svg_icon/file_url
) to allow the use of an SVG file from a rewrited URL for example.
I hope you will appreciate this solution. I will try to fix this issue during the week.