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
Hello Friends, i'm trying to get image or image url from already published content (like blogpost)
i have Media Picker called "image", uploaded image file in content and
Looks like the "Model" object in your view is not the right. Can you show the whole view code?
@using ContentModels = Umbraco.Web.PublishedModels;
Layout = "master.cshtml";
is "Service" your doctype alias?
yes sure. :(
Have a look at the media picker documentation here on how to get the image to be printed out.
Hope this helps,
This works for me but there are too many lines for only 1 image or image url :/ , is there any other solutions?
var typedMediaPickerSingle = Model.Value<IPublishedContent>("image");
if (typedMediaPickerSingle != null)
<img src="@typedMediaPickerSingle.Url" style="width:200px" />
Of course, we can do it a bit simpler
if (Model.Value<IPublishedContent>("featuredBanner") != null)
<img src='@Model.Value<IPublishedContent>("featuredBanner").Url' />
)f I was you then I will make that extra variable so you don't have to write Model.Value
All the best,
how to make it as extra variable? what do you mean?
I think Dennis wanted to say that code with extra variable looks better and more efficient, like this:
var featuredBanner = Model.Value<IPublishedContent>("featuredBanner");
if (featuredBanner != null)
<img src='@featuredBanner.Url' />
have you tried reloading/generating your models in Umbraco backoffice? Maybe after generating, double check if your service model has the "image" property.
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted