Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Tom 713 posts 952 karma points
    Oct 06, 2011 @ 03:16
    Tom
    0

    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

  • Dirk De Grave 4537 posts 6006 karma points MVP 3x admin c-trib
    Oct 06, 2011 @ 09:09
    Dirk De Grave
    1

    Hi,

    DynamicMedia lives in the umbraco.MacroEngines namespace, so you'll need an extra @using statement 

    @using umbraco.MacroEngines

     

    Hope this helps.

    Regards,

    /Dirk

  • Dan Diplo 1505 posts 5911 karma points MVP 4x c-trib
    Oct 06, 2011 @ 10:52
    Dan Diplo
    1

    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);

  • Tom 713 posts 952 karma points
    Oct 07, 2011 @ 00:16
    Tom
    0

    Thank you both very much! I do appreciate your replies! will upgrade to 4.7.1 at the same time! :)

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies