When I change @Umbraco.Media(slide.Image).umbracoFile to what you suggested I get the following error:
Cannot perform runtime binding on a null reference
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: Microsoft.CSharp.RuntimeBinder.RuntimeBinderException: Cannot perform runtime binding on a null reference
on this line:
@foreach(dynamic slide in sliderNode.Children) {
Yet that same line exists further up the script no problem, and if I remove your suggestion and put back in the original line everything runs as normal but without images. I can verify in the raw HTML that all three slides are created, titles and taglines are visible, but the mediafile returns ''. And yes the 1117 that is returned is correct.
Umbraco v7.6 is by default geared to using Model.Content rather than CurrentPage and also includes converters so that content and media pickers return object rather than Id's
Umbraco.Media(ID).mediafile not working on 7.6?
Did something change? This code works fine in Umbraco 7.5.x, our new 7.6.x install results in blank strings.
slide.image results in 1117 Umbraco.Media(slide.image).umbracoFile results in ' '
Hi Tim
Try this one:
:( That breaks the page altogether
What is the error? are you sure that result of slide.image is ID?
Ok sorry about that delay....here is my entire macro:
When I change @Umbraco.Media(slide.Image).umbracoFile to what you suggested I get the following error:
Cannot perform runtime binding on a null reference Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: Microsoft.CSharp.RuntimeBinder.RuntimeBinderException: Cannot perform runtime binding on a null reference
on this line:
Yet that same line exists further up the script no problem, and if I remove your suggestion and put back in the original line everything runs as normal but without images. I can verify in the raw HTML that all three slides are created, titles and taglines are visible, but the mediafile returns ''. And yes the 1117 that is returned is correct.
Have you tried using
@Tim where does sliderNode come from?
My bad, I didn't include the top three lines, had attention split!!
Hi Tim
Try to print what is in slide.Image?
Is it right id? Does this media item exist?
Alex
@Alex Brown
I tried your suggestion and that provides an empty string as well.
I changed the line to use @slide["image"] to verify the ID is correct and here is the output.
Give this a try
Umbraco v7.6 is by default geared to using Model.Content rather than CurrentPage and also includes converters so that content and media pickers return object rather than Id's
That did Jeavon!
Looks like I'll have to study up on the new gearing! Thanks for the fix and point me to the knowledge!!!
No problem, it would also be worth looking into using Models Builder, that allows you to write evens simpler code
Never even heard of that, thanks!
If you have a .tv sub, I would recommend this video series http://umbraco.tv/videos/umbraco-v7/implementor/working-with-umbraco-data/go-further-with-models-builder/
is working on a reply...