Copied to clipboard

Flag this post as spam?

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


  • hetaurhet 245 posts 267 karma points
    Dec 20, 2011 @ 11:43
    hetaurhet
    0

    accessing media picker in xslt in umbraco 4.7

    I am using 4.7 version.

    How can I access media picker image that is selected in xslt?

     

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Dec 20, 2011 @ 21:56
    Tom Fulton
    0

    Hi,

    Check out this blog post from Lee Kelleher which has a code sample:  How to use umbraco.library GetMedia in XSLT for Umbraco v4.5

    -Tom

  • hetaurhet 245 posts 267 karma points
    Dec 21, 2011 @ 06:43
    hetaurhet
    0

    Tom , but I am using 4.7.0. So I need code for that.

  • Pasang Tamang 258 posts 458 karma points
    Dec 21, 2011 @ 07:31
    Pasang Tamang
    1

    Hello,

    The example in which Tom provide works on 4.7.0 also. Umbraco 4.5+ is based on new schema.

    Here is one more example:

      <xsl:if test="number($currentPage/siteLogo) &gt; 0">
        <img src="{umbraco.library:GetMedia($currentPage/siteLogo,false)/umbracoFile}" alt="Logo"/>
      </xsl:if>

     the siteLogo is the media picker property name

    Thanks

    PTamang

  • hetaurhet 245 posts 267 karma points
    Dec 21, 2011 @ 07:57
    hetaurhet
    0

    thanx...

     

    But it is not working...

    see the code below

    <?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" xmlns:fulltextsearch.search="urn:fulltextsearch.search" xmlns:fulltextsearch.helper="urn:fulltextsearch.helper"
      exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets fulltextsearch.search fulltextsearch.helper ">


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

    <xsl:param name="currentPage"/>

    <xsl:template match="/">

    <!-- start writing XSLT -->
      <xsl:if test="number($currentPage/NodeImage) &gt; 0">
                <img src="{umbraco.library:GetMedia($currentPage/NodeImage,false)/umbracoFile}" alt="image"/>
              </xsl:if>

    </xsl:template>

    </xsl:stylesheet>

    also actually I want to modify relatedlinks xslt. I want to access media pickker image field (field name-nodeImage) of the nodes which are added in related links. So that for all links, link title along with image(media picker) of that particular page are shown as list.

    so how can I access that node? as I just have related link urls in the xslt.

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Dec 21, 2011 @ 14:04
    Tom Fulton
    0

    Hi,

    As Pasang mentioned the code is the same for all versions 4.5+ so that should work.

    What isn't working about Pasang's code - are you getting an error when saving, not getting an <img> tag back or getting an <img> tag with a broken image?

    Are you sure the current page has a property with the alias NodeImage?  Usually the property names start with lowercase ie nodeImage.

    Also, you can apply the same practice to Related Links, but instead of $currentPage you can get the "picked" page using umbraco.library:GetXmlNodeById(), ex:

    <!-- inside your related links for-each loop.... -->
    <xsl:variable name="pickedPage" select="umbraco.library:GetXmlNodeById(./@link)"/> <!-- grabs the picked page by accessing the link attribute from your related links xml -->
    <xsl:if test="not($pickedPage/error)"> <!-- makes sure the page still exists -->
      <xsl:if test="number($pickedPage/NodeImage) &gt; 0">
        <img src="{umbraco.library:GetMedia($pickedPage/NodeImage,false())/umbracoFile}" alt="image"/>
      </xsl:if>
    </xsl:if>

    -Tom

  • hetaurhet 245 posts 267 karma points
    Dec 21, 2011 @ 14:33
    hetaurhet
    0

    hi Tom,

    yes u r right.... propertyname is nodeImage .... and also thank you for giving code of pickedpage... it is not showing image

Please Sign in or register to post replies

Write your reply to:

Draft