Copied to clipboard

Flag this post as spam?

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


  • Mark Davies 1 post 21 karma points
    Jul 29, 2011 @ 23:18
    Mark Davies
    0

    Standard noob GetMedia question

     

    Hi guys,

    Just starting out with Umbraco and running into a pretty standard problem (from looking around the web) - but no solutions seem to work for me at all. I'm using Umbraco 4.7.0.

    Bascially what I'm trying to do is to display a html image tag for an uploaded asset, using a macro with XSLT.

    I have a page structure:

    - Top Level

     - Client Page

       - Project Page

    ... the asset is an "upload" property called "clientLogo" of the Client Page document type, and I want to be able to display that asset in all Client Pages and all Project Pages. The image is the client logo. Here's my XSLT:

     

    <xsl:template match="/">

    <xsl:variable name="mediaId" select="number($currentPage/clientLogo)" />

    <xsl:if test="$mediaId > 0">

    <xsl:variable name="mediaNode" select="umbraco.library:GetMedia($mediaId, 0)" />

    <xsl:if test="$mediaNode/umbracoFile">

    <img src="{$mediaNode/umbracoFile}" alt="[image]" height="{umbracoHeight}" width="{umbracoWidth}" />

    </xsl:if>

    </xsl:if>

    </xsl:template>

    But this outputs nothing at all. Any help MUCH appreciated, been banging my head against this all day.

    Cheers,

    Mark.

  • Dennis Aaen 4457 posts 17970 karma points admin hq c-trib
    Jul 29, 2011 @ 23:51
    Dennis Aaen
    0

    Hi Mark,

    If I understand your explanation correct you have a property called "clientLogo" based on the upload datatype.

    Maybe this will you work for you.

    <xsl:paramname="currentPage"/>

    <xsl:templatematch="/">
           
    <xsl:apply-templatesselect="$currentPage/clientLogo[normalize-space()]"/>
    </xsl:template>

    <xsl:templatematch="clientLogo">
           
    <img src="{.}" alt="[image]" height="{umbracoHeight}" width="{umbracoWidth}" />
    </xsl:template>

    I haven“t tested it myself, but I hope it can helps you.

    May I ask why you are use the Upload data type and not the media picker datatype?

    /Dennis

     

     

  • Dennis Aaen 4457 posts 17970 karma points admin hq c-trib
    Jul 30, 2011 @ 00:04
    Dennis Aaen
    0

    Hi agian Mark,
    When you are using an upload data type does not allow you to use umbracoWidth and UmbracoHeight.

    But take a look at uComponents and their GetImageHeight extension. You can find more about it here.
    http://ucomponents.codeplex.com/wikipage?title=Media&referringTitle=Documentation

    /Dennis

  • Fuji Kusaka 2203 posts 4220 karma points
    Jul 30, 2011 @ 04:12
    Fuji Kusaka
    0

    Hi Mark,

    Basically you just want to display the uploaded image right?...so you dont want the user to upload images which might break your layout as well. You could try this

    <xsl:if test="clientLogo !=' ' ">
    <xsl:element name="img"><xsl:attribute name="src">
     <xsl:value-of select="clientLogo "/>
    </xsl:attribute>
    <xsl:attribute name="width"><xsl:value-of select="umbracoWidth"/></xsl:attribute>
    </xsl:element>
    </xsl:if>

     

    //fuji

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies