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 folks, how do you find image url?
I have tried drilling down into the properties, I receive a null reference at the following code Udi tempImageUrl = mediaItem.Url;
Full code below
public ActionResult RenderFeatured() { List<FeaturedItem> model = new List<FeaturedItem>(); IPublishedContent homePage = CurrentPage.AncestorOrSelf(1).DescendantsOrSelf().Where(x => x.DocumentTypeAlias == "home").FirstOrDefault(); ArchetypeModel featuredItems = homePage.GetPropertyValue<ArchetypeModel>("featuredItems"); foreach (ArchetypeFieldsetModel fieldset in featuredItems) { Udi imageId = fieldset.GetValue<Udi>("image"); var mediaItem = Umbraco.Media(imageId); Udi tempImageUrl = mediaItem.Url; string imageUrl = tempImageUrl.ToString();
Does that node have a image/ is the node publishd?
Put a breakpoint and step through it.
try something like:
string imageId = fieldset.GetValue<string>("image"); var mediaItem = Umbraco.Media(imageId);
Thanks Rob :)
Hi Guys
Be aware that "Umbraco.Media" returns dynamic type object, it's better to use Umbraco.TpyedMedia()
Thanks,
Alex
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.
Continue discussion
Find the url of Image
Hi folks, how do you find image url?
I have tried drilling down into the properties, I receive a null reference at the following code Udi tempImageUrl = mediaItem.Url;
Full code below
Does that node have a image/ is the node publishd?
Put a breakpoint and step through it.
try something like:
Thanks Rob :)
Hi Guys
Be aware that "Umbraco.Media" returns dynamic type object, it's better to use Umbraco.TpyedMedia()
Thanks,
Alex
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.