Copied to clipboard

Flag this post as spam?

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


  • Howard Dierking 12 posts 32 karma points
    Aug 17, 2010 @ 07:03
    Howard Dierking
    0

    Can't get media path from id

    Running Umbraco 4.5.1

    I'm trying to create what I thought was a pretty standard XLST + Macro to extract the URL for a media library item from its id.  I'm trying to tes this with a known ID - so the following

    <xsl:value-of select="umbraco.library:GetMedia('1092', false())/umbracofile"/>

    unfortunately, I get no output

    I tried backing up and looking at the entire result of teh GetMedia call with the following

    <xsl:copy-of select="umbraco.library:GetMedia('1092', false())"/>

    but the result was much less than helpful - in fact, the result wasn't even well formed

        <img id="1092"
            version="18deca79-9a45-44a6-95f2-2c66a78bc6c3"
            parentid="1089"
            level="3"
            writerid="0"
            nodetype="1032"
            template="0"
            sortorder="3"
            createdate="2010-08-16T10:42:34"
            updatedate="2010-08-16T10:42:34"
            nodename="bullet.gif"
            urlname="bullet.gif"
            writername="Administrator"
            nodetypealias="Image"
            path="-1,1088,1089,1092"
        >
        <umbracofile>/media/1092/bullet.gif</umbracofile>
        <umbracowidth>4</umbracowidth>
        <umbracoheight>8</umbracoheight>
        <umbracobytes>49</umbracobytes>
        <umbracoextension>gif</umbracoextension>

    Anybody have an idea what I could be doing wrong here?

    tia,

    _howard

  • Sebastiaan Janssen 5060 posts 15522 karma points MVP admin hq
    Aug 17, 2010 @ 08:30
    Sebastiaan Janssen
    0

    Looks like it's well formed to me! :-)

    Have a look at Lee Kelleher's blogpost about getting media items, that should help.

  • Sascha Wolter 615 posts 1101 karma points
    Aug 17, 2010 @ 08:30
    Sascha Wolter
    0

    Hi Howard,

    that is indeed very odd. I have made a quick test on my 4.5.1 install with the following Xslt:

      <xsl:variable name="image" select="umbraco.library:GetMedia(1049, false())" />
      <textarea style="width: 200px; height: 200px;">
        <xsl:copy-of select="$image" />
      </textarea>
      <br />url: <xsl:value-of select="$image/umbracoFile" />

    This is the output:

    <Image id="1049" version="070a23ce-d837-493e-8c14-3d454bfbc4aa" parentID="-1" level="1" writerID="0" nodeType="1032" template="0" sortOrder="0" createDate="2010-08-10T23:26:33" updateDate="2010-08-10T23:26:33" nodeName="asdf" urlName="asdf" writerName="Administrator" nodeTypeAlias="Image" path="-1,1049">
      <umbracoFile>/media/7/about.png</umbracoFile>
      <umbracoWidth>16</umbracoWidth>
      <umbracoHeight>16</umbracoHeight>
      <umbracoBytes>931</umbracoBytes>
      <umbracoExtension>png</umbracoExtension>
    </Image>
    url: /media/7/about.png
    

    So it is quite odd that you get img instead of Image and everything is lowercase in your example wherease the node names as definitely camel case. You can check this in the database in the table ContentXml. I have no idea why you only get the results, however try out umbracoFile instead of umbracofile and see what happens.

    Cheers,
    Sascha

  • Jesper Ordrup 1019 posts 1528 karma points MVP
    Aug 17, 2010 @ 08:46
    Jesper Ordrup
    0

    Hi Howard,

    This seems like a bug. Please consider adding this as a issue in http://umbraco.codeplex.com if it's not there already. I sure would like this not to happen on one of mine. :-)

    /Jesper

  • Arjan H. 226 posts 463 karma points c-trib
    Aug 17, 2010 @ 10:36
    Arjan H.
    1

    This call is case-sensitive:

    <xsl:value-of select="umbraco.library:GetMedia('1092', false())/umbracofile"/>

    Should be:

    <xsl:value-of select="umbraco.library:GetMedia('1092', false())/umbracoFile"/>
  • Howard Dierking 12 posts 32 karma points
    Aug 17, 2010 @ 21:58
    Howard Dierking
    0

    after some investigation, it turns out that there were 2 things going on:

    1) As Arjan noted, my casing was wrong on umbracoFile - getting the case right fixed the immediate problem

    2) the weird behavior that I ran into seems to be a real bug in the XSLT visualizer - more specifically in how the encode/decode result feature works.  For example, if I write out the XML results to a textarea, I see the proper XML, but if I just write it directly (e.g. just the copy-of instruction), the markup is as I reported earlier when I click 'encode/decode result'

    I'll submit this bug to codeplex and mark Arjan's reply as the answer.

    thanks,

    _howard

Please Sign in or register to post replies

Write your reply to:

Draft