I am trying to select images from a nodes children (first screenshot provided).
As you can see, the Image child-node contains a text-string (image caption) and a media picker (picking an image from the media folder).
In the macro (third image), I have tried to dumb it down as much as possible. But, when I try to load the page, I get an error (fourth image). Using ?umbdebug I get the error-message shown in image 5.
Issue with Library.MediaById (Razor)
Hello.
Screenshots: http://imgur.com/a/b8WL5
I am trying to select images from a nodes children (first screenshot provided).
As you can see, the Image child-node contains a text-string (image caption) and a media picker (picking an image from the media folder).
In the macro (third image), I have tried to dumb it down as much as possible. But, when I try to load the page, I get an error (fourth image). Using ?umbdebug I get the error-message shown in image 5.
Please advice.
I'd be very insterested in knowing which namespace you imported to actually be able to even USE @Library - I was looking for this all last night.
Exactly which Umbraco version are you using?
v4.7.1.1
It should be part of the MacroEngines namespace, which is imported already?
What you see in my Razor-script is the entire script.
The issue definitely has something to do with Library using Examine to locate(?) the media, but examine not working properly.
I have not changed any settings regarding Examine however, and I'm puzzled with this behavior.
Okay, you might not have to use Library directly, does this work for you:
Note that I'm dancing between versions here (there are so many breaking changes it's unbelievable), so this is much of a guess.
Hm, not exactly:
'The name 'Umbraco' does not exist in the current context'
Does importing the the namespace, as below, help:
At the top of the file, but below the @inherits specifier.
No change.
I tried changing the code a bit:
The Model.GetMediaUrl(1147) (1147 = id of the media file) returns an empty string.
It doesn't matter whether I use node.image/node.Image or hardcode the ID.
The node.imageCaptionTitle returns the correct value though.
Hrm. Made it work. Don't really like my solution though, it seems a bit too much trial-and-error-colored. :P
Hi, Ole. The Library.MediaById should work well this way:
is working on a reply...