Copied to clipboard

Flag this post as spam?

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


  • Shaun 248 posts 475 karma points
    Feb 11, 2009 @ 19:33
    Shaun
    0

    GetMedia nightmares

    Hello.

    I'm trying to write a XSLT file triggered by a Macro that will display an image that has been uploaded using the media picker.

    If I use the following code

    [code]



    [/code]

    it returns the following url.

    /media/100/single-logo.gif45045039931gif

    the first bit of which is correct. I have no idea what the second bit is.

    If I use another bit of code suggested by Dirk in another forum

    [code]



    [/code]

    I get no errors in the xsl edit panel, but the following is output to the page.

    Error parsing XSLT file: \xslt\BoxList.xslt

    I'm at my wits end. I only want to display an image!](*,)

  • Shaun 248 posts 475 karma points
    Feb 11, 2009 @ 20:13
    Shaun
    0

    Forget it, Its solved. I was bringing the whole node back as I hadn't specified which bit I wanted.

    Not sure what the other bit of code was doing to generate the error but it's working now.

  • Brittany 3 posts 71 karma points
    Feb 13, 2009 @ 20:56
    Brittany
    0

    I'm having the same issue, what did you do to fix it?

  • Shaun 248 posts 475 karma points
    Feb 14, 2009 @ 08:48
    Shaun
    0

    Hi MediaCrisis

    This is the line that fixed the issue for me

    [code]

    [/code]

    I'd forgotten to put the /data blah blah blah bit on the end. So Umbraco was pulling back the whole node. That was why I was getting what appeared to be 2 filenames jammed together. For some reason my brain really doesnt want to learn XSLT syntax!

  • martin 259 posts 31 karma points
    Jul 22, 2009 @ 00:33
    martin
    0

    I'm up against the same problem with the filename but it seems the new forum has eaten your solution.

    as a matter of fact any code snippets inserted into the forum prior to this new forum have disappeared???

    man how friggin frustration is this

  • Tom Maton 387 posts 660 karma points
    Jul 31, 2009 @ 13:37
    Tom Maton
    1

    Martin this is the original forum message

    http://forum.umbraco.org/yaf_postst8180_GetMedia-nightmares.aspx

    With all the code in :)

  • teus 42 posts 74 karma points
    Jul 14, 2010 @ 17:02
    teus
    0

    Hello,

    I'm using Umbraco 4.5 and I'm getting a similar long link but I do not understand how to get ONLY the path. 1135 is an id of a picture in Media. The code returns

    <img src="/media/1435/nieuws2.jpgjpg14694"> which is to much obviously. 

    select="umbraco.library:GetMedia(1155, 0)/data [@alias = 'umbracoFile']" returns nothing (<img src="">).

    Help would be much appreciated ;-)

     

    Teus

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp "&#x00A0;"> ]>
    <xsl:stylesheet
      version="1.0"
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
      xmlns:msxml="urn:schemas-microsoft-com:xslt"
      xmlns:umbraco.library="urn:umbraco.library" xmlns:Exslt.ExsltCommon="urn:Exslt.ExsltCommon" xmlns:Exslt.ExsltDatesAndTimes="urn:Exslt.ExsltDatesAndTimes" xmlns:Exslt.ExsltMath="urn:Exslt.ExsltMath" xmlns:Exslt.ExsltRegularExpressions="urn:Exslt.ExsltRegularExpressions" xmlns:Exslt.ExsltStrings="urn:Exslt.ExsltStrings" xmlns:Exslt.ExsltSets="urn:Exslt.ExsltSets"
      exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets ">

    <xsl:output method="xml" omit-xml-declaration="yes"/>

    <xsl:param name="currentPage"/>

    <xsl:template match="/">
    <xsl:variable name="Banner" select="umbraco.library:GetMedia(1135, 0)"/>
    B<img src="{$Banner}"/>


    </xsl:template>

    </xsl:stylesheet>
  • dandrayne 1138 posts 2262 karma points
    Jul 14, 2010 @ 17:15
    dandrayne
    0

    Hi Teus

    In 4.5 the syntax is a little different due tot he different xml schema

    <xsl:variable name="Banner" select="umbraco.library:GetMedia(1135, 0)/*/umbracoFile"/>

    Should get you the path to the file

    Dan

  • teus 42 posts 74 karma points
    Jul 15, 2010 @ 10:53
    teus
    0

    Thanks Dan, that was the trick. Is there documentation somewhere about this ?

    And another question springs to mind: 

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

    produces the xml of the media item:

    <file id="1135" 
        version="8aabae69-333a-4f98-a91b-3e542792a6aa"
        parentid="-1"
        level="1"
        writerid="0"
        nodetype="1033"
        template="0"
        sortorder="81"
        createdate="2010-07-13T11:11:26"
        updatedate="2010-07-13T11:11:29"
        nodename="Nieuws2"
        urlname="nieuws2"
        writername="Administrator"
        nodetypealias="File"
        path="-1,1135">

        <umbracofile>/media/1435/nieuws2.jpg</umbracofile>
        <umbracoextension>jpg</umbracoextension>
        <umbracobytes>14694</umbracobytes>
    </file>

     

    So why doesn't this(* = file) work? (Please note that I studied XSLT for 3 hours ;-) )

    <xsl:variable name="Banner" select="umbraco.library:GetMedia(1135, 0)/file/umbracoFile"/>

     

  • dandrayne 1138 posts 2262 karma points
    Jul 15, 2010 @ 11:13
    dandrayne
    0

    Hi Teus

    Using true() as the second paramater instead of false() or 0 actually recursively gets all media nodes under the selected node as well.  This can be a bit of a performance hog so is best avoided unless you specifically want the children of the selected media item.

    The default media file node is called File, so this should work

    <xsl:variable name="Banner" select="umbraco.library:GetMedia(1135, 0)/File/umbracoFile"/>

    Also, you may want to watch that it's a File and not an Image.  If it could be either then you'd be best to use the * selector.

    Also this wiki page may help -> http://our.umbraco.org/wiki/reference/xslt/45-xml-schema

    Hope this helps,
    Dan

  • teus 42 posts 74 karma points
    Jul 16, 2010 @ 11:22
    teus
    0

    Thanks Dan, thats clear.

    Teus

Please Sign in or register to post replies

Write your reply to:

Draft