From the changelog for 4.7.2 it appears some changes in fetching media with Razor has been made. However I'm not sure what has been the issue earlier on and how it has been fixed.
But what happens if you cast the property to a string? Like this (string)Model.RelatedMedia !=0
Same problem. I made several attempts.The type returned by GetType is System.String
I'll note that the macro is available in the default combobox for Umbraco. If Umbraco's developers have changed something, had to change the macro too.
Hmmm yes then it looks like it it's a bug, which should be reported at codeplex - If you report it as a bug at some point please post a link to the issue in here so others who come accross this issue can vote it up.
I'll of course let you know if I figure something out on how to solve the issue.
Another strange similar problem. Before 4.7.2 this code line run:
@Model.prodottoPrezzo.ToString("c")
The type of fields is Currency. With 4.7.2, if thefield value isa number withdecimal (ex. 12.45), all run. If thefield value isa number withoutdecimal (ex. 12), the macro render "Error loading MacroEngine script"
<p>Advanced: <br /> @{ var image = @Model.Media("pageMast"); } <img src='@image.UmbracoFile' alt='@image.Name' /> </p> } else { <p> This page doesn't contain a MediaPicker property with the alias of 'RelatedMedia' or No image is selected on this page </p> }
4.7.2 break standard razor macros
Hi
The standard Umbraco Media Macro stop working with Umbraco 4.7.2.
...
@inherits umbraco.MacroEngines.DynamicNodeContext
@if (Model.HasProperty("relatedMedia") && Model.RelatedMedia != 0) {
<p>Simple: <br />
<img src='@Model.Media("relatedMedia", "umbracoFile")' />
</p>
...
return "Error loading MacroEngine script (file: )"
The problem is in the if statement. This script
@if (Model.HasProperty("immagineTesto") )
work. The test
Model.immagineTesto!= 0
return error.
Hi Gionata
From the changelog for 4.7.2 it appears some changes in fetching media with Razor has been made. However I'm not sure what has been the issue earlier on and how it has been fixed.
But what happens if you cast the property to a string? Like this (string)Model.RelatedMedia !=0
/Jan
Hi Jan
Same problem. I made several attempts.The type returned by GetType is System.String
I'll note that the macro is available in the default combobox for Umbraco. If Umbraco's developers have changed something, had to change the macro too.
Gionata
Hi Gionata
Hmmm yes then it looks like it it's a bug, which should be reported at codeplex - If you report it as a bug at some point please post a link to the issue in here so others who come accross this issue can vote it up.
I'll of course let you know if I figure something out on how to solve the issue.
/Jan
Another strange similar problem. Before 4.7.2 this code line run:
@Model.prodottoPrezzo.ToString("c")
The type of fields is Currency. With 4.7.2, if the field value is a number with decimal (ex. 12.45), all run. If the field value is a number without decimal (ex. 12), the macro render "Error loading MacroEngine script"
Gionata
Created http://umbraco.codeplex.com/workitem/30810.
Also created http://umbraco.codeplex.com/workitem/30811, for the following problem
The code line
foreach (Media pic in gallery.GetDescendants())
seem not working with 4.7.2!
I know this reply is a few months late.... but I changed the script slightly and it works for me in 4.9.0
@inherits umbraco.MacroEngines.DynamicNodeContext
@if (Model.HasProperty("pageMast") && Model.Media("pageMast") != null) {
<p>Simple: <br />
<img src='@Model.Media("pageMast", "umbracoFile")' />
</p>
<p>Advanced: <br />
@{
var image = @Model.Media("pageMast");
}
<img src='@image.UmbracoFile' alt='@image.Name' />
</p>
} else {
<p>
This page doesn't contain a MediaPicker property with the alias of 'RelatedMedia'
or No image is selected on this page
</p>
}
is working on a reply...