Umbraco: How to get Media in code-behind

To get a media (i.e.: image)  in code-behind you can do it like this.

var currentPage = umbraco.presentation.nodeFactory.Node.GetCurrent();
var media = new umbraco.cms.businesslogic.media.Media(
            Convert.ToInt32(currentPage.GetProperty("[property]").Value)
    );
string imageUrl = media.getProperty("umbracoFile").Value.ToString();


Posted

in

by

Comments

One response to “Umbraco: How to get Media in code-behind”

  1. Levan Avatar
    Levan

    Works like a charm. Thank you!

Leave a Reply

Your email address will not be published. Required fields are marked *