Copied to clipboard

Flag this post as spam?

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


  • Anthony Candaele 1197 posts 2049 karma points
    Feb 12, 2011 @ 12:27
    Anthony Candaele
    0

    problem with getMedia

     

    Hi,

    I am trying to show a banner image in my webpages.

    The user can choose with Media Picker a banner image from the Media Library:

    in my getbannerimage.xslt file I use the getMedia method to render my image tag:

    <xsl:value-of select="umbraco.library:GetMedia($currentPage/banner, 0)/Image/umbracoFile" />

    But for some reason, the image is not showing, the src attribute of the image tag is empty.

    What am I doing wrong?

    Thanks for your help,

    Anthony Candaele
    Belgium

  • Anthony Candaele 1197 posts 2049 karma points
    Feb 12, 2011 @ 12:37
    Anthony Candaele
    0

    just checking if it is possible to reply

  • Jan Skovgaard 11280 posts 23678 karma points MVP 10x admin c-trib
    Feb 12, 2011 @ 12:37
    Jan Skovgaard
    0

    Hi Anthony

    a good idea is to see if you get anything from the banner property.

    you can do this like this

    <textarea>

    <xsl:copy-of select="$currentPage/banner" />

    </textarea>

    If this returns an id you should make a copy of your umbraco.library:GetMedia($currentPage/banner,0) to see what XML gets returned. It's probably because your match is wrong in some way, or perhaps you just need to republish the entire site?

    Have you had a look at the wiki entry about the usage of GetMedia? http://our.umbraco.org/wiki/reference/umbracolibrary/getmedia

    Hope these pointers are helpful.

    /Jan

  • Simon Kibsgård 62 posts 73 karma points
    Feb 12, 2011 @ 12:40
    Simon Kibsgård
    1

    Hi Anthony

    Try this

    <xsl:if test="$currentPage/banner &gt; 0">
      <img src="{umbraco.library:GetMedia($currentPage/banner,'true')/umbracoFile}" />
    </xsl:if>
  • Jan Skovgaard 11280 posts 23678 karma points MVP 10x admin c-trib
    Feb 12, 2011 @ 12:45
    Jan Skovgaard
    0

    Hi Simon

    the example you provide is wrong.

    if you want to use either true or false instead of 0 or 1 in the expression you should use false() or true() - the way you have done it it will always return true. You could write anything in there like 'test' and it would be interpreted as "true".

    Using 'false" and 'true' is a comon misconception I think - I know I have been guilty of doing it myself in the past untill mr. Steinmeier wrote about how to deal with it.

    Cheers

    /Jan

  • Jan Skovgaard 11280 posts 23678 karma points MVP 10x admin c-trib
    Feb 12, 2011 @ 12:48
    Jan Skovgaard
    1

    Hi again

    Forgort to mention that 0,1,false() and true() should be written without '' sourounding it...For an example like this:

      <img src="{umbraco.library:GetMedia($currentPage/banner,true())/umbracoFile}" />
  • Anthony Candaele 1197 posts 2049 karma points
    Feb 12, 2011 @ 12:53
    Anthony Candaele
    0

    Hi Jan,

    Thanks, the problem is solved, apparently

    <img src="{umbraco.library:GetMedia($currentPage/banner,true())/Image/umbracoFile}" />

    doesn't give back the image file information, while

    <img src="{umbraco.library:GetMedia($currentPage/banner,true())/umbracoFile}" />

    Does!

    Thanks, now I can have lunch with some peace of mind :)

    Anthony

  • Jan Skovgaard 11280 posts 23678 karma points MVP 10x admin c-trib
    Feb 12, 2011 @ 12:57
    Jan Skovgaard
    0

    Hi Anthony

    Happy to hear you got it sorted out. It can sometime be frustrating when it's the little things that's confusing one :-)

    Enjoy your lunch.

    /Jan

  • Simon Kibsgård 62 posts 73 karma points
    Feb 12, 2011 @ 12:58
    Simon Kibsgård
    0

    cool Jan, thnx

Please Sign in or register to post replies

Write your reply to:

Draft