There is a check for a null value in case no image has been select in your code above. Please try and check if an image has in fact been selected in the content section for the page that you're trying to see in your browser.
If an image has indeed been selected could it perhaps then be some sort of caching issue you experience?
Ok sorry if I stated the obvious above but you never know and I myself have been making mistakes where I have been looking at the wrong page instead of the one where the image was inserted - Sometimes it's those small silly things :-)
Hmm...What happens if you try rendering the image without the null check? Or if you just try to render @mainPostImage just above your null check?
I suspect that it will probably render the media id. So you should actually try to do something like (from the top of my head)
Hmm, that's odd? I assume that your for loop from the initial post did work before you changed anything, right? If so please try this example, which is a modified version of what you originally posted.
And when starting out the less confusion the better ;-) - The reason why you need to use Umbraco.TypedMedia is because what you get is a media id and the TypedMedia method accept an integer in order to figure out what media item has been selected btw :)
Rendering media picker image
Hi,
So I have the following partial
and I'm trying to render the image that I have selected in from the media library, this is how the data type is set up.
But it doesn't seem to render here is the output I'm getting
Hi Ben
There is a check for a null value in case no image has been select in your code above. Please try and check if an image has in fact been selected in the content section for the page that you're trying to see in your browser.
If an image has indeed been selected could it perhaps then be some sort of caching issue you experience?
/Jan
I do have an image selected yes.
I have tried in incognito, but the same result
Hi Ben
Ok sorry if I stated the obvious above but you never know and I myself have been making mistakes where I have been looking at the wrong page instead of the one where the image was inserted - Sometimes it's those small silly things :-)
Hmm...What happens if you try rendering the image without the null check? Or if you just try to render
@mainPostImage
just above your null check?I suspect that it will probably render the media id. So you should actually try to do something like (from the top of my head)
Does that work for you?
/Jan
Hi Jan,
Ok I've just tried
and I just get a runtime error, I get this
Hi Ben
Argh! Sorry that I'm confusing you - Also it's just now that I notice you're inside a loop! My bad :-)
You should write it like this then
This should do the trick - Once again sorry for the confusion previously!
/Jan
Hi Jan,
Don't worry about it, this is all new to me so I'm still seeing how everything works.
Apparently, I have a parse error but I'm not seeing it.
Hi Ben
Hmm, that's odd? I assume that your for loop from the initial post did work before you changed anything, right? If so please try this example, which is a modified version of what you originally posted.
Does this work for you?
And when starting out the less confusion the better ;-) - The reason why you need to use Umbraco.TypedMedia is because what you get is a media id and the TypedMedia method accept an integer in order to figure out what media item has been selected btw :)
/Jan
Hi Jan,
Ok, that worked, thank you for the explanation, it's very helpful.
Hi Ben
Delighted to hear that! Happy coding :)
/Jan
is working on a reply...