acf-svg-icon icon indicating copy to clipboard operation
acf-svg-icon copied to clipboard

svg files fixed for theme path

Open badabingbreda opened this issue 6 years ago • 1 comments

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.

badabingbreda avatar Nov 03 '18 08:11 badabingbreda

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 :

  1. 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.
  2. 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.

7studio avatar Nov 05 '18 21:11 7studio