Copied to clipboard

Flag this post as spam?

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


  • Barbacan 29 posts 79 karma points
    Dec 02, 2016 @ 12:22
    Barbacan
    0

    Getting DAMP image while using contentService

    Hi, I'm writing a custom control and I have a content type with DAMP property valorized. The DAMP is configured to store the data as full media xml, so this is my structure:

    <damp fullmedia="">
      <mediaitem>
        <img id="1119" version="29a5623f-d41c-4418-97b7-3cea8579ffd8" parentid="1052" level="2" writerid="0" nodetype="1032" template="0" sortorder="2" createdate="2016-11-30T10:09:40" updatedate="2016-11-30T10:09:40" nodename="2016-11-25_1251411957-277" urlname="2016-11-25_1251411957-277" writername="admin" nodetypealias="Image" path="-1,1052,1119">
          <umbracofile>/media/1013/2016-11-25_1251411957-277.jpg</umbracofile>
          <umbracowidth>2598</umbracowidth>
          <umbracoheight>1732</umbracoheight>
          <umbracobytes>350613</umbracobytes>
          <umbracoextension>jpg</umbracoextension>    
      </mediaitem>
    </damp>
    

    Basically I need to extract the "umbracofile" property. The basic object is an IContent and the property is "mediaContent". With Razor I would do this:

    if (news.HasValue("mediaContent"))
    {
        var image = news.mediaContent.FirstOrDefault();
        var imageUrl = image.Image; 
        var imageName = Path.GetFileNameWithoutExtension(@imageUrl.umbracoFile);
    }
    

    but in this case I'm managing an IContent. This is what I've done so far:

    if ((e.Item.ItemType != ListItemType.Item && e.Item.ItemType != ListItemType.AlternatingItem)) return;
    var user = e.Item.DataItem as IContent;
    if (user != null)
    {
        if (user.GetValue<dynamic>("mediaContent")!=null)
        {
            var image = user.GetValue<string>("mediaContent");  //test
            //var imageUrl = image.Image;
            //var imageName = System.IO.Path.GetFileNameWithoutExtension(imageUrl.umbracoFile);
        }
    }
    

    Any hints?

Please Sign in or register to post replies

Write your reply to:

Draft