Render image from a theme inside Orchard Render image from a theme inside Orchard asp.net asp.net

Render image from a theme inside Orchard


There are couple of ways of achieving that. The best way would be to pass the URL to Url.Content(...) helper method like this:

    <img src="@Url.Content(Html.ThemePath(WorkContext.CurrentTheme, "/Content/Header.jpg"))" />

which will render the proper path to your content. You can also just strip the leading tilde (~) like Html.ThemePath(WorkContext.CurrentTheme, "/Content/Header.jpg").Skip(1), which will give you the path relative to the app root, but that is not a good solution though.


You could of course use the Html.Image helper as well.

@Html.Image(Html.ThemePath(WorkContext.CurrentTheme,"/Content/Header.jpg"), "Alt Text", null)

Thank you for this - just picking up Orchard as well.