Copied to clipboard

Flag this post as spam?

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


  • Justin Spradlin 139 posts 347 karma points
    Oct 04, 2011 @ 08:15
    Justin Spradlin
    0

    Dynamic Properties invalid in Razor

    Hi, 

    I have recently upgrade to 4.7.1 and I am pretty sure that this did not happen then. I am trying to render a image tag for a document type "MediaElement" that captures the "Media" and "Thumbnail". Media and Thumbnail are both files picked using the S3 plugin. However I am not getting the correct value back from the dynamicNode in razor. 

    Here are the values that I am seeing in Razor:

    element.Media
    {umbraco.MacroEngines.DynamicXml}
        base {System.Dynamic.DynamicObject}: {umbraco.MacroEngines.DynamicXml}
        BaseElement: <value dataTypeId="1135"><![CDATA[cdn.mydomain.com/FIG 1 TB HOCM MMODE AV.004.004.jpg]]></value>
        InnerText: "cdn.mydomain.com/FIG 1 TB HOCM MMODE AV.004.004.jpg"
    element.PropertiesAsList[3]
    {<value dataTypeId="1135"><![CDATA[cdn.mydomain.com/FIG 1 TB HOCM M-MODE AV.004.004.jpg]]></value>}
        Alias: "media"
        Value: "<value dataTypeId=\"1135\"><![CDATA[cdn.mydomain.com/FIG 1 TB HOCM M-MODE AV.004.004.jpg]]></value>"
        Version: {00000000-0000-0000-0000-000000000000}

    The value of the element.PropertiesAsList[3] (which corresponds to the "Media" node is correct. Notice that the "-" has been removed from the InnerText of the element.Media version (causing invalid data). So when I try to render my node using this bit of razor, it renders an invalid value for the src of my image tag. 

     

    var mediaUrl = XDocument.Parse(element.Media.ToXml()).Element("value").Value; 
    var thumbnailUrl = XDocument.Parse(element.Thumbnail.ToXml()).Element("value").Value;
    
    // This doesn't work either
    // var mediaUrl = element.Media.BaseElement.Value;
    // var thumbnailUrl = element.Thumbnail.BaseElement.Value;

    Here is a snipped from the umbraco.config for this node

    <Playlist id="1165" parentID="1147" level="2" writerID="1" creatorID="0" nodeType="1094" template="0" sortOrder="4" createDate="2011-06-18T09:12:09" updateDate="2011-07-18T19:36:54" nodeName="Fig 1 TB" urlName="fig-1-tb" writerName="tommy" creatorName="admin" path="-1,1147,1165" isDoc="">
          <embedCode><![CDATA[e038cbf3-b443-4d19-8b17-d80ec31da211]]></embedCode>
          <PlaylistElement id="1166" parentID="1165" level="3" writerID="1" creatorID="0" nodeType="1093" template="0" sortOrder="1" createDate="2011-06-18T09:13:21" updateDate="2011-07-18T19:36:54" nodeName="figure 1 TB" urlName="figure-1-tb" writerName="tommy" creatorName="admin" path="-1,1147,1165,1166" isDoc="">
            <title>FIG 1 TB</title>
            <description><![CDATA[]]></description>
            <elementType><![CDATA[Image]]></elementType>
            <media>
              <value dataTypeId="1135"><![CDATA[cdn.mydomain.com/FIG 1 TB HOCM M-MODE AV.004.004.jpg]]></value>
            </media>
            <thumbnail>
              <value dataTypeId="1135"><![CDATA[cdn.mydomain.com/FIG 1 TB HOCM M-MODE AV.004.004.jpg]]></value>
            </thumbnail>
          </PlaylistElement>
        </Playlist>          

    Does anyone have any ideas about how I can fix this?

    Thank you,

    Justin

Please Sign in or register to post replies

Write your reply to:

Draft