Get an absolute asset/icon path for custom components using wwLib

Hi! I’ve found some ways to get an absolute path from wwLib:

  1. wwLib.useIcons() // suggested by AI
  2. wwLib.wwUtils.getImgCdnUrl(path)

Also I’ve found a couple of functions which return cdn base path, but if we’re using custom paths for assets, I’m not sure if I’ll get the right path.

Asked on WeWeb OfficeHours.

What’s the most solid and update-proof way to get it?

@flo @Matthew_S

Hey Anton :waving_hand: ,

I checked with one of our devs on this. The most reliable way to get the absolute path isn’t through wwLib functions, but by using the actual asset path directly.

For images:

<website-url>/images/<img-name>

For files:

<website-url>/files/<file-name>

I hope this helps.

You mentioned getting the absolute path of an icon from the project - what is your use case?

1 Like

The case is when I need some icon to be shown inside my component. Thank you for those templates-placeholders. I’ll try them.