(the reason for the .ToString() is after I switched from Obsolete to Media.Picker2 - so since it's string)
In my Umbraco 11.1 I was struggle to display the images.
I tried the following and it didn't display the images, but also didn't throw an error, just didn't display the images:
I also tried this one (the same as above, just with @ - @newsItem) , and this throw an error: "Argument 3: cannot convert from 'method group' to 'object?'":
Yes, I have read it before, but what it shows in the examples is parsing the Guid:
var mediaItem = Umbraco.Media(Guid.Parse("55240594-b265-4fc2-b1c1-feffc5cf9571"));
So I wasn’t sure how to get the Guid of each image? It wasn’t clear from the docs. It seems in the examples that they pretty much hard coding the Guid.
But if I iterate over a node, how do I get the Guid of each item in a node? (each item in the node represents a page with a feature image)
Let’s say I have a node which I’m iterating, how do I get the Guid for each node to retrieve the image?
Render images in Umbraco 11
Hi, In my Umbraco 7.15.7 I'm displaying images in the Partial Views Macro Files as follow:
(the reason for the .ToString() is after I switched from Obsolete to Media.Picker2 - so since it's string)
In my Umbraco 11.1 I was struggle to display the images. I tried the following and it didn't display the images, but also didn't throw an error, just didn't display the images:
So I tried this one:
And this one also doesn't show any image
I also tried this one (the same as above, just with @ - @newsItem) , and this throw an error: "Argument 3: cannot convert from 'method group' to 'object?'":
So I tried this one:
And this is finally works! And I don't understand why? (why this works, and why the previous didn't work)
My question are:
Why only the last one works?
Why the first two doesn't work?
Is this is the right way to render images in Umbraco 11.1 ?
Please advise.
Thanks.
Have a read of the docs
https://docs.umbraco.com/umbraco-cms/fundamentals/design/rendering-media
Yes, I have read it before, but what it shows in the examples is parsing the Guid:
var mediaItem = Umbraco.Media(Guid.Parse("55240594-b265-4fc2-b1c1-feffc5cf9571"));
So I wasn’t sure how to get the Guid of each image? It wasn’t clear from the docs. It seems in the examples that they pretty much hard coding the Guid. But if I iterate over a node, how do I get the Guid of each item in a node? (each item in the node represents a page with a feature image)
Let’s say I have a node which I’m iterating, how do I get the Guid for each node to retrieve the image?
If you follow the links for mediapicker etc it shows examples using the alias as well
https://docs.umbraco.com/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/media-picker-3
Since I migrated from 7 in my database I'm still using Umbraco.MediaPicker (and not Umbraco.MediaPicker3)
So I can't use IEnumerable
https://docs.umbraco.com/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/media-picker
is working on a reply...