Finally trying out v8 and testing bit by bit to move over my active site.
However when I try to get the image URL from a simple selection of my featureItemsPage.
The image is selected with the media picker data type.
I get the following error: Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
Line 18: @if(item.HasValue("featureImage"))
Line 19: {
Line 20: var image = item.Value<IPublishedContent>("featureImage");
Line 21: <a href="#" class="image featured"><img src="@image.Url" alt="" /></a>
Line 22: }
Get image url from selection (V8) not working
Hi all,
Finally trying out v8 and testing bit by bit to move over my active site. However when I try to get the image URL from a simple selection of my featureItemsPage.
The image is selected with the media picker data type.
I get the following error: Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
Probably a simple issue and V8 newbie mistake.
Thx!
Hello DonZalMrol ,
@if(item.HasValue("featureImage")) {
var image = item.Value
Can you please try Below..!!!!!!
@if(item.HasValue("featureImage"))
Just Add Close () in the end @image.Url()
If Above not work Try Below
Replace IpublishContent With Media With Crops.
Thanks,
Shekhar
Hi Shekhar, thanks! Unfortunately, no luck :(
Are you using the old MediaPicker or the latest MediaPicker 3?
with the new MediaPicker you need to do
After changing the code to your suggestion the page now loads with the image!
Thanks!
No problem, had the same issue myself over the weekend when i changed to the new media picker :D
Ha :D
is working on a reply...