Copied to clipboard

Flag this post as spam?

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


  • Dave 48 posts 68 karma points
    May 23, 2011 @ 14:29
    Dave
    0

    GetMedia problem

    Hi

    Got a starnge problem (to me) that hopefully one of you fine chaps can solve for me.
    I have a macro that I copied from a 3 installation and modified it (hopefully correctly) to be used in 4.5.2.

    When the macro runs, the getmedia filename ouput has a string appended to it and the image cannot be found in the html..

    Code is 

          <xsl:if test="string-length(/macro/Image) &gt; 0">
            <div id="InfoBoxImage" style="background-color:#F0F0F0;width:223px;">
              <xsl:if test="string-length(/macro/ImageURL) &gt; 0">
                <a href="{/macro/ImageURL}">
                  <img style="width: 223px; height: 100px;">
                    <xsl:attribute name="src">
                      <xsl:value-of select="umbraco.library:GetMedia($MediaID, 0)" />
                    </xsl:attribute>
                    <xsl:attribute name="title">
                      <xsl:value-of select="/macro/title" />
                    </xsl:attribute>
                  </img>
                </a>
              </xsl:if>

    And the view source of the webpage shows the png filename as

    src="/media/22/fw_new_callout_01.png223557543png"


    Its the 223557543png bit that is appended (which is the concatenated width/height/size/type of the image).

    How do I prevent that happening?

    Cheers

    Dave

     

     

     

  • Tom Fulton 2030 posts 4998 karma points c-trib
    May 23, 2011 @ 14:34
    Tom Fulton
    0

    Hi Dave,

    You should change your GetMedia call to the following

                    <xsl:attribute name="src">
                      <xsl:value-of select="umbraco.library:GetMedia($MediaID, 0)/umbracoFile" />
                    </xsl:attribute>

    Right now you are grabbing the entire Media XML with GetMedia, which includes umbracoBytes and umbracoExt (the two strings you see at the end of your file).  You should just grab the umbracoFile element in this case

    Hope this helps,
    Tom

     

     

  • Rich Green 2246 posts 4008 karma points
    May 23, 2011 @ 14:39
    Rich Green
    0

    Hi,

    I'm not 100% sure what your code is doing and where '$MediaID' is coming from.

    However if /macro/image is a image picker then try this:

     <xsl:variable name="mediaId" select="number(/macro/Image)" />

    <xsl:if test="$mediaId > 0"> <xsl:variable name="mediaNode" select="umbraco.library:GetMedia($mediaId, 0)" /> <xsl:if test="$mediaNode/umbracoFile"> <img src="{$mediaNode/umbracoFile}" height="{umbracoHeight}" width="{umbracoWidth}" /> </xsl:if> </xsl:if>

    Rich

  • Dave 48 posts 68 karma points
    May 23, 2011 @ 14:47
    Dave
    0

    @Tom - Thanks for that - you saved me from tearing out what is left of my hair!

Please Sign in or register to post replies

Write your reply to:

Draft