In this tutorial, you will learn how to render images in Umbraco CMS. The Umbraco media picker property will allow a content editor to upload an image onto a page within the CMS. When it comes to rendering the image within a view, you may notice that the media picker only returns the asset id and not the Url. In your views/view models if you want to link to the image then you will need to query the Umbraco API to get the full Url. In today's post, I'm going to quickly cover how you can do that.
How To Get The Url For An Image?
To get the URL for images you will need to use the Umbraco helper. This is possible using this snippet:
If you want to use the Url in a route-hijacked controller and not within your view/controller, you may need to access the Umbraco Helper directly yourself. You can do this, like this:
This code will now give you the assets Url to use how you need. Happy Coding 🤘