Copied to clipboard

Flag this post as spam?

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


  • René Andersen 238 posts 684 karma points
    May 29, 2013 @ 09:12
    René Andersen
    0

    Showing multiple images with DAMP

    Hi

    I cant figure out why this script does not work. I get this error when I debug in Visual Studio:

    Cannot implicitly convert type 'umbraco.MacroEngines.DynamicNode' to 'System.Collections.IEnumerable'. An explicit conversion exists (are you missing a cast?).

    The error is shown on "foreach".

    What I want the script to do is showing multiple images with DAMP Classic. (No crop etc.)

    @inherits umbraco.MacroEngines.DynamicNodeContext
    @using DigibizAdvancedMediaPicker;

    @{
    foreach (dynamic media in Model.MediaById(Model.imageDamp))
    {
    <img src="@media.umbracoFile" alt="@media.nodeName"/>
    }
    }

    Thanks in advance!

    //René

  • Jeroen Breuer 4909 posts 12266 karma points MVP 5x admin c-trib
    Jun 18, 2013 @ 12:15
    Jeroen Breuer
    0

    You can't use the foreach here because Model.MediaById will only return 1 object and not something which is enumerable. If you make sure that the DAMP Classic can only select 1 media item which stores the id something like this should work:

    var media = Model.MediaById(Model.imageDamp);
    <img src="@media.umbracoFile" alt="@media.nodeName"/>

    Jeroen

  • 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