Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Hi
If anyone could offer any help would be greatly appreciated. This one is driving me mad.
I'm displaying some child pages in a template and have an image in the pages that I'd like to display and am strggling getting the Url of that image.
@{ var navitem = CurrentPage.Children.Where("Visible"); } @{foreach (var item in navitem) { <div class="col-xs-4"> <div class="news-item"> <h2> @item.pageTitle</h2> <p> <i class="fa fa-calendar" aria-hidden="true">@item.UpdateDate.ToString("dd MMMM yyyy")</i><br /></p> <p class="news-intro"> @item.introText </p> <img src="@item.newsImage"> </div> </div> } }
Its @item.newsImage where I'm just getting the ID. Does anyone know how to convert that to the URL.
Thanks.
Hi David
Use this code:
<img src="@Umbraco.Media(item.newsImage).Url">
Also be aware that dynamics isn't the best practice for using.
Thanks,
Alex
Thanks Alex, little change but worked fine.
@{int newsImageId = item.newsImage; } <img src="@Umbraco.Media(newsImageId).Url">
Glad to help you!
Have a great evening!
Hi Alex and David I got the same problem but the solution doesn't work for me as I am using this ImageId in another page (partial view). I am getting the value from template
@foreach(var item in selection){ <section > @Html.Partial("/Views/Partials/Sections/" + @item.SectionType + ".cshtml", new ViewDataDictionary { {"text", @item.PageContent}, {"image", @item.Image}, {"heading", @item.Heading} }) </section> }
and passing it to a partial view
var imageUrl = ViewData["image"]; <div class="col-md-5 text-center"><img class="content-section-img" src="@imageUrl" alt=" " /> </div>
Any idea? Thanks
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Get URL of Media Picker Image
Hi
If anyone could offer any help would be greatly appreciated. This one is driving me mad.
I'm displaying some child pages in a template and have an image in the pages that I'd like to display and am strggling getting the Url of that image.
Its @item.newsImage where I'm just getting the ID. Does anyone know how to convert that to the URL.
Thanks.
Hi David
Use this code:
Also be aware that dynamics isn't the best practice for using.
Thanks,
Alex
Thanks Alex, little change but worked fine.
Glad to help you!
Have a great evening!
Hi Alex and David I got the same problem but the solution doesn't work for me as I am using this ImageId in another page (partial view). I am getting the value from template
and passing it to a partial view
Any idea? Thanks
is working on a reply...