Copied to clipboard

Flag this post as spam?

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


  • Martin 278 posts 662 karma points
    Jul 28, 2014 @ 15:29
    Martin
    0

    Multi Media Picker

    Hi, having some trouble with setting up a multiple media picker within a switch block.

    Razor is new to me and I could use a little help referencing the images. im getting the node id's but cant seem to get correct razor to display the image.

     

    Any help would be grateful.

    @{var widgetsFolder = Model.WidgetsFolders.Where("Visible").First();}
    @foreach (dynamic widget in widgetsFolder.Children.Where("Visible and nodeTypeAlias.StartsWith(\"Widget_\")")) {
      string widgetType = widget.NodeTypeAlias.ToString();
      switch (widgetType) {
        case "Widget_LogoList":
        @showLogos(widget);
        break;      
        default:
        <b>Unknown Widget!</b>
        break;
      }
    }
    @helper showLogos(dynamic widget) {
      @* @widget.logoItem; - OUTPUTS ID OF IMAGE NODE *@
      if (!string.IsNullOrEmpty(Model.logoItem.ToString()))
      {
        dynamic mediaItem = Library.MediaById(Model.logoItem);
        <img src="@mediaItem.umbracoFile" alt="@mediaItem.Name" />
      }
    }
  • Martin 278 posts 662 karma points
    Jul 29, 2014 @ 10:32
    Martin
    100

    Somehow got it working

    if (!string.IsNullOrEmpty(widget.multiLogo.ToString()))
    {
        var logoItem = widget.multiLogo.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
        var logoGroup = Library.MediaById(logoItem);
    
        foreach (var logo in logoGroup)
        {
            <img src="@logo.umbracoFile"  />
        }
    } 
    
Please Sign in or register to post replies

Write your reply to:

Draft