Path to image in js with wp_localize_script [closed]

Aside from the fact that you shouldn’t use get_bloginfo('template_url'), but rather get_template_directory_uri() or it’s *_stylesheet_*() equivalent, it’s a JavaScript problem: The localized object shouldn’t be wrapped in quotes:

// Wrong
url : 'svg_path.template_url+"/svg/plus.svg"',

// Right:
url : svg_path.template_url + "/svg/plus.svg",

When handling JavaScript, simply use console.log( svg_path ) in your script to see the output in your browsers developer tools console.

tech