How can I dynamically reference images from my assets via javascript?



I’d like to dynamically reference images from my assets (uploaded images) via javascript. How can I do that?

The only solution I’ve come up until now is to put all images into the page and hide them first via display:none css code. But this will cause the page to load all images in advance.

I’d really like to keep the assets on unbounce and not split it up to external resources from another server if not necessary.

Any ideas?


Hi Paul - while you’re not able to reference images directly from your image library, what you could do is load all of the images to a separate Unbounce page. As long as that page remains published and in your account, those image links will remain static, so you could reference the links from that page and only load the necessary ones on your actual landing page as needed.


ugly :wink:

how about a global javascript funktion like “getUnbounceResourceUrl(‘image-name’)” which takes care of that?