Copied to clipboard

Flag this post as spam?

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


  • Darryl Godden 145 posts 197 karma points
    Oct 11, 2011 @ 13:16
    Darryl Godden
    0

    GetMedia - not working

    Hi all,

    I have a media picker and I am trying to display using Lee's advice from his blog, I have this:

    <xsl:variable name="mediaId" select="number($currentPage/data[@alias='jobPostingBusinessUnitLogo'])" />    
    <xsl:if test="$mediaId &gt; 0">
          <xsl:variable name="mediaNode" select="umbraco.library:GetMedia($mediaId, 0)" />
          <xsl:if test="count($mediaNode/data) &gt; 0 and string($mediaNode/data[@alias='umbracoFile']) != ''">
            <img src="{$mediaNode/data[@alias='umbracoFile']}" alt="[image]" height="{$mediaNode/data[@alias='umbracoHeight']}" width="{$mediaNode/data[@alias='umbracoWidth']}" />
          </xsl:if>
        </xsl:if>

    I'm not getting any output and if I do a value-of on mediaId I get NaN. I've checked the field in the umbraco.config:

    <jobPostingBusinessUnit><![CDATA[NEC Group]]></jobPostingBusinessUnit>
              <jobPostingBusinessUnitLogo>1230</jobPostingBusinessUnitLogo>
              <jobPostingClosingDate>2011-10-24T00:00:00</jobPostingClosingDate>
              <jobPostingJobType><![CDATA[Permanent]]></jobPostingJobType>
              <jobPostingSalary>24,000</jobPostingSalary>
              <jobPostingPaymentSchedule><![CDATA[]]></jobPostingPaymentSchedule>

    and it exists and is a number.

    Thanks

  • Rodion Novoselov 694 posts 859 karma points
    Oct 11, 2011 @ 13:20
    Rodion Novoselov
    0

    Hi, Darryl. What schema version do you use? This xslt seems to target the old one.

  • Darryl Godden 145 posts 197 karma points
    Oct 11, 2011 @ 13:21
    Darryl Godden
    0

    4.7.0 Rodion

  • Darryl Godden 145 posts 197 karma points
    Oct 11, 2011 @ 13:24
    Darryl Godden
    0

    1.0 XML

  • Rodion Novoselov 694 posts 859 karma points
    Oct 11, 2011 @ 13:31
    Rodion Novoselov
    0

    Try to change your script to something like this:

    <xsl:if test="$mediaId &gt; 0">
          <xsl:variable name="mediaNode"
                        
    select="umbraco.library:GetMedia($mediaId, 0)" />
          <xsl:if test="$mediaNode/Image/umbracoFile != ''">
            <img src="{$mediaNode/Image/umbracoFile}" alt="[image]"
                 
    height="{$mediaNode/Image/umbracoHeight}"
                 
    width="{$mediaNode/Image/umbracoWidth}" />
          </xsl:if>
    </xsl:if>
  • Darryl Godden 145 posts 197 karma points
    Oct 11, 2011 @ 13:34
    Darryl Godden
    0

    Hi Rodion,

    I hadn't noticed Lee's blog post was from 2009, we've got it working with this:

    <img src="{umbraco.library:GetMedia(jobPostingBusinessUnitLogo, 0) /umbracoFile}"/>

    Just need to check if an image has been selected.

    Thanks for your help.

Please Sign in or register to post replies

Write your reply to:

Draft