Copied to clipboard

Flag this post as spam?

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


  • Manish 373 posts 929 karma points
    Feb 15, 2017 @ 10:53
    Manish
    0

    Multiple media picker in Macro

    Hi

    I am getting

    as

        {src: '/media/1116/abc.png', crops: [
      {
        "alias": "banner",
        "width": 900,
        "height": 400
      },
      {
        "alias": "TopBanner",
        "width": 488,
        "height": 265
      }
    ]}
    

    I want only src part. I am using macro and this is ok if there is pdf but for image it is giving me this path.

    How can i make it work for both image and pdf files.

    Thanks

  • Manish 373 posts 929 karma points
    Feb 15, 2017 @ 10:55
    Manish
    0

    My code is

     var file = Parameter.Downloadable_File;
        var mediaList = file.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
        var mediaCollection = Model.MediaById(mediaList);
    
    
    
    ///Loop
      @foreach (var item in mediaCollection)
                    {
      <a href="@item.umbracoFile" class="article-footer__link download-link" target="_blank" download>
    
    }
    

    I want to make it work for both image and pdf but in case of image it returns json path which i mentioned above

  • Manish 373 posts 929 karma points
    Feb 15, 2017 @ 12:39
    Manish
    0

    I am able to do it this way so any type of file can be used

      if (item.NodeTypeAlias == "Image")
                    {
                        var imageCrops = JsonConvert.DeserializeObject<ImageCropDataSet>(item.umbracoFile);
                        href = imageCrops.Src;
                    }
                    else
                    {
                        href = item.umbracoFile;
                    }
    

    Thanks

  • 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