Copied to clipboard

Flag this post as spam?

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


  • Nick Hillman 6 posts 96 karma points
    Dec 18, 2019 @ 14:06
    Nick Hillman
    0

    multimediapicker in a macro umbraco 8

    Hi, I'm struggling with the multiplemediapicker within a macro for umbraco version 8+. Has anyone got a code example of how to render out the filetype, url, and name. I'm trying to setup a macro with a multiple document selector for downloadable files. Many thanks, Nick

  • Pasang Tamang 252 posts 394 karma points
    Dec 18, 2019 @ 16:14
    Pasang Tamang
    0

    Hi Nick,

    Which version of Umbraco you are using? In Umbraco 8.4.0 I have seen multi media picker available as macro parameter. Similar topic discussion can be found here https://github.com/umbraco/Umbraco-CMS/issues/5335.

    Thanks

  • Nick Hillman 6 posts 96 karma points
    Dec 27, 2019 @ 10:35
    Nick Hillman
    0

    It's Umbraco 8.0 through to 8.3 (various different projects at different stages of development)

  • Nick Hillman 6 posts 96 karma points
    Dec 27, 2019 @ 10:44
    Nick Hillman
    100

    I managed to work out a solution to this (while developing something else)...

    This presents a block presentation with an icon image depending on file type (plus a catch-all) there is also a custom parameter of description added to the media library.

    @{ string MediaItems = (Model.MacroParameters["MediaItems"]).ToString(); string[] split = MediaItems.Split(',');

      var fileType = "";
      var fileTypeShort = "";
      var fileImage = "";
    
          foreach (string item in split)
          {
              var MediaItem = Umbraco.Media(item);
    
              fileType = MediaItem.Value("umbracoExtension").ToString();
    
              fileTypeShort = fileType;
              if (fileType.Length > 3){
                  fileTypeShort = fileType.Substring(0,3);
              }
    
              switch(fileTypeShort)
              {
                  case "pdf":
                      fileImage = "/media/hc3hugna/pdf-512.png";
                      break;
                  case "doc":
                      fileImage = "/media/2e3j4t2d/doc-512.png";
                      break;
                  case "xls":
                      fileImage = "/media/qo1ofzed/xls-512.png";
                      break;
                  case "ppt":
                      fileImage = "/media/agkeop1t/ppt-512.png";
                      break;
                  case "png":
                      fileImage = MediaItem.Url;
                      break;
                  case "jpg":
                      fileImage = MediaItem.Url;
                      break;
                  case "eps":
                      fileImage = "/media/zavk1qr1/eps-512.png";
                      break;
                  case "ai":
                      fileImage = "/media/qx2lifel/ai-512.png";
                      break;
                  default:
                      fileImage = "/media/3i4dy4jh/other-512.png";
                      break;
              }
              <a href="@MediaItem.Url" class="btn-link" target="_blank">
                  <div class="downloadItem downloadType@(MediaItem.Value("umbracoExtension")) row">
                      <div class="col-4" style="text-align: center; ">
                          <img style="background: #efefef; max-width: 100%; max-height:100px; object-fit: contain;" src="@fileImage" />
                      </div>
                      <div class="col-8">
                          <p><strong>@MediaItem.Name</strong> (@(MediaItem.Value("umbracoExtension"))) </p>
                          <p>@MediaItem.Value("description") </p>
    
                      </div>
                  </div>
              </a>
          }
    

    }

  • 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