Copied to clipboard

Flag this post as spam?

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


  • Bambu 4 posts 24 karma points
    Jul 28, 2011 @ 10:45
    Bambu
    0

    How get a Media with Umbraco 4.7

    hi,

    i'm working with umbraco 4.7 and i'm trying to show a image. I use the next code but don't show the image. Anybody knows why?

    My xslt:

    <?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:param name="currentPage"/>

    <xsl:variable name="mediaPropName" select="/macro/imagen" />

    <xsl:template match="/">

    <xsl:variable name="media" select="umbraco.library:GetMedia($currentPage/@alias=$mediaPropName, 0) " />
    <img src="{$media/umbracoFile}" alt="{$media/altText}" />

    </xsl:template>

    </xsl:stylesheet>

     

    Thanks

  • Bas Schouten 135 posts 233 karma points
    Jul 28, 2011 @ 10:59
    Bas Schouten
    0

    Hi Bambu,

    It should be something like this:

    <xsl:variablename="media"select="umbraco.library:GetMedia($currentPage/imageAlias, 0)"/>

    <xsl:iftest="$media">
    <imgsrc="{$media/umbracoFile}"alt="{$media/altText}"/>
    </xsl:if>

    You dont need the @alias= anymore.

    For more info look at: http://our.umbraco.org/wiki/reference/umbracolibrary/getmedia

    Cheers,

    Bas

  • Bambu 4 posts 24 karma points
    Jul 28, 2011 @ 11:13
    Bambu
    0

    hi Bas,

    the problem is that i need "imageAlias" will be a parameter macro, how can i declare it? When i debbug my xslt the @alias value is null (don't take my parameter), althoutht $mediaPropName takes the value right of my property name which make reference to extended media Picker (damp: classic).

    I saw this page (our.umbraco.org/.../getmedia), but i think that is obsolet because i'm working with 4.7 version and this page talks about Umbraco 4.5.1.

    Thanks 

  • Fuji Kusaka 2203 posts 4220 karma points
    Jul 28, 2011 @ 11:25
    Fuji Kusaka
    0

    Hi Bambu,

     

    You could try this

    <img src="{concat(substring-before(umbraco.library:GetMedia(alias, 'true'),'.'),'.jpg')}" />

     

    //Fuji

  • Bambu 4 posts 24 karma points
    Jul 28, 2011 @ 11:53
    Bambu
    0

    Hi Fiji,

    that doesn't work to me.

    Thanks

  • Sergio 73 posts 93 karma points
    Jul 28, 2011 @ 12:03
    Sergio
    0

    Hi,

    Finally is working with this code:

    <xsl:variable name="mediaPropName" select="/macro/imagen" />

    <xsl:template match="/">

     <xsl:variable name="media" select="umbraco.library:GetMedia($currentPage/* [name() = $mediaPropName], 0)" />
     
      <img src="{$media/umbracoFile}" alt="{$media/altText}" />

    Regards.

     

  • Fuji Kusaka 2203 posts 4220 karma points
    Jul 28, 2011 @ 12:09
    Fuji Kusaka
    0

    Hey Bambu,


    Good if you got it working, so  i assume your alias name in your document type is mediaPropName? Are you using the upload field in your Document type?

    Thats weird i got it working like this

    <imgsrc="{concat(substring-before(umbraco.library:GetMedia(mediaPropName, 'true'),'.'),'.jpg')}"/>

    //fuji

  • Sergio 73 posts 93 karma points
    Jul 28, 2011 @ 12:37
    Sergio
    0

    No, we are using the DAMP-Classic Datatype.

     

Please Sign in or register to post replies

Write your reply to:

Draft