Getting the url of an image inside public folder

I have a external js file named acf-map.js and i want to use themap-pin.png image inside the public folder,

var image = {
		url: '/wp-content/themes/npr2023/public/images/map-pin.png',
		// This marker is 19 pixels wide by 32 pixels high.
		size: new google.maps.Size(19, 32),
		// The origin for this image is (0, 0).
		origin: new google.maps.Point(0, 0),
		// The anchor for this image is the base of the flagpole at (0, 32).
		anchor: new google.maps.Point(0, 32)
	};

This throws an error, it cannot find the image url because image has a prefix after the build.

You should be able to import those assets:

1 Like

I already have this as my bud.config.js

  app
    .entry('app', ['@scripts/app', '@styles/app'])
    .entry('editor', ['@scripts/editor', '@styles/editor'])
    .assets(['images', 'fonts',])
    .assets({
        from: app.path(`@scripts/custom/acf-map.js`),
        to: app.path(`public/js/acf-map.js`),
      });

But issue isi i want to use the image on my external js

So that external JavaScript file is not built by bud?
You can copy files without hashing the filename (example), so those URLs are stable and can be used in the external JavaScript.