Copied to clipboard

Flag this post as spam?

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


  • Maksim 12 posts 34 karma points
    Nov 03, 2011 @ 10:10
    Maksim
    0

    GetMedia() returns empty string after update to 4.7.1

    Hi, guys!

    I've updated my web site from 3.0.6. to 4.7.1 version. (and updated my xslt scripts to fit new xml schema).

    I'm trying to get image url (image id = 1292)

     

    <?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"
      exclude-result-prefixes="msxml umbraco.library">
    <xsl:output method="xml" omit-xml-declaration="yes"/>
    <xsl:template match="/">
    <xsl:variable name="mediaId" select="//macro/mediaId"/>
    <xsl:if test="$mediaId">
      <xsl:value-of select="$mediaId/node/@id" />
      <!-- returns 1292 - ok-->
      <!-- <xsl:value-of select="umbraco.library:GetMedia($mediaId/node/@id,'false')/data[@alias='umbracoFile']"/>  -->
      <xsl:value-of select="umbraco.library:GetMedia(1292,0)" />
      <!-- returns empty string!-->
      <xsl:copy-of select="umbraco.library:GetMedia(1292,0)" />
      <!-- returns empty string!-->
    </xsl:if>
    </xsl:template>
    </xsl:stylesheet>

     

    I've found a lot of similar posts, but issue always related with new xml schema and code like

    <xsl:value-of select="umbraco.library:GetMedia(1292,0)" />

    always returns some value. I can't even get any value from GetMedia() method.

    However,

    <xsl:value-of select="umbraco.library:GetMedia(2,0)" />

    returns "No media is maching '2'"

    Can anybody help me?

     

  • Rich Green 2246 posts 4008 karma points
    Nov 03, 2011 @ 10:31
    Rich Green
    0

    Hi,

    Welcome to the forum.

    Did you try and republish the media item?

    Rich

  • Maksim 12 posts 34 karma points
    Nov 03, 2011 @ 10:53
    Maksim
    0

    Yes, it works after i ckicked "Save" button of media item. Thank you Rich!

  • Jeroen Breuer 4908 posts 12265 karma points MVP 4x admin c-trib
    Nov 03, 2011 @ 11:48
    Jeroen Breuer
    0

    If you want to republish all media items you could try the Create Crops package. Even if you don't have any crops it will also republish all media items.

    Jeroen

  • Maksim 12 posts 34 karma points
    Nov 03, 2011 @ 11:51
    Maksim
    0

    Thanks, it should be very usefull

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Nov 03, 2011 @ 13:13
    Tom Fulton
    1

    FYI, you can also visit the following URL which should republish all your media items.  I've had to do this when upgrading from older versions:    /umbraco/dialogs/republish.aspx?xml=true

Please Sign in or register to post replies

Write your reply to:

Draft