Error loading Razor Script c:\Users\tom\Dev\PasticheWholesale\Cms\App_Data\TEMP\Razor\inline-1d37f148180ae735f0839fe03def70d9.cshtml(4): error CS0246: The type or namespace name 'DynamicMedia' could not be found (are you missing a using directive or an assembly reference?)
Hi guys trying to use DynamicMedia.. without success.. I've followed the examples from the razor walkthrough and it's juist not working
DynamicMedia Fail?
<umbraco:Macro runat="server" language="cshtml">
@inherits umbraco.MacroEngines.DynamicNodeContext
@{
if(Model.HasProperty("collectionHeroImage") && Model.collectionHeroImage != 0) {
dynamic mediaItem = new DynamicMedia(@Model.collectionHeroImage);
if(mediaItem != null) {
<img src="@mediaItem.umbracoFile" width="@mediaItem.umbracoWidth" height="@mediaItem.umbracoHeight" alt="@mediaItem.Name"/>
}
}
}
</umbraco:Macro>
Error loading Razor Script
c:\Users\tom\Dev\PasticheWholesale\Cms\App_Data\TEMP\Razor\inline-1d37f148180ae735f0839fe03def70d9.cshtml(4): error CS0246: The type or namespace name 'DynamicMedia' could not be found (are you missing a using directive or an assembly reference?)
Hi guys trying to use DynamicMedia.. without success.. I've followed the examples from the razor walkthrough and it's juist not working
thanks,
Tom
Hi,
DynamicMedia lives in the umbraco.MacroEngines namespace, so you'll need an extra @using statement
Hope this helps.
Regards,
/Dirk
Dirk is correct, you will need to include the umbraco.MacroEngines namespace.
In addition, in Umbraco 4.7.1 it is best practice to create a new media file using this syntax:
dynamic mediaItem = Library.MediaById(@Model.collectionHeroImage);
Thank you both very much! I do appreciate your replies! will upgrade to 4.7.1 at the same time! :)
is working on a reply...