Render image from a theme inside Orchard

后端 未结 2 2009
死守一世寂寞
死守一世寂寞 2021-02-19 11:11

I\'ve just picked up Orchard for building my blog. As part of my endeavour to create this new weblog I\'m creating a custom theme. This custom theme features both CSS and images

相关标签:
2条回答
  • 2021-02-19 11:49

    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.

    0 讨论(0)
  • 2021-02-19 11:55

    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.

    0 讨论(0)
提交回复
热议问题