Copied to clipboard

Flag this post as spam?

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


  • Ryan Farghil 9 posts 29 karma points
    Jun 01, 2011 @ 19:21
    Ryan Farghil
    0

    How to work with images?

    Please forgive how basic this question is.  Bought the book, searched the forums, watched the videos, and still learning how to do this.

    How do we create a website page that has an image which can be changed by the user?  Don't want to use the rich text editor, just want a link somewhere on the content section that sez "upload the image for your page".  It looks like we need to use some xslt to extract the content node for the image, but I am not clear on the procedure.  What do we need to add?  Using Umbraco 4.7, all ideas greatly appreciated.

     

  • Ryan Farghil 9 posts 29 karma points
    Jun 01, 2011 @ 19:38
    Ryan Farghil
    0

    Realized a bit more info might help... here is the master page:

    <asp:Content ContentPlaceHolderID="cp_content" runat="server">
     HERE IS AN IMAGE : <umbraco:Macro PropertyAlias="HomePageImage" Alias="MediaOutput" runat="server"></umbraco:Macro>
    </asp:Content>

    ...and here is quite a simple document type:

    ...and here is the xslt:

        <xsl:output method="xml" omit-xml-declaration="yes"/>
        <xsl:param name="currentPage"/>
        <xsl:variable name="propertyAlias" select="/macro/propertyAlias"/>
        <xsl:variable name="propertyValue" select="$currentPage/* [name()=$propertyAlias]"/>
       
        <xsl:template match="/">
            <!-- check to make sure the property value that we pass in is not empty -->
            <xsl:if test="$propertyValue!=''">
                <!-- localize the media nodeset into a shorter variable name for readability -->
                <xsl:variable name="mediaItem" select="umbraco.library:GetMedia($propertyValue, 'false')"/>
                <xsl:if test="$mediaItem!=''">
                    <img>
                        <xsl:attribute name="src">
                            <xsl:value-of select="$mediaItem/umbracoFile" />
                        </xsl:attribute>
                        <xsl:attribute name="width">
                            <xsl:value-of select="$mediaItem/umbracoWidth" />
                        </xsl:attribute>
                        <xsl:attribute name="height">
                            <xsl:value-of select="$mediaItem/umbracoHeight" />
                        </xsl:attribute>
                        <xsl:attribute name="alt">
                            <xsl:value-of select="$mediaItem/@nodeName" />
                        </xsl:attribute>
                    </img>
                </xsl:if>
            </xsl:if>
        </xsl:template>

    What are we missing please?

  • Nik Wahlberg 639 posts 1237 karma points MVP
    Jun 01, 2011 @ 21:15
    Nik Wahlberg
    0

    Hi, there. The only thing I can think of is that you don't have your macro paramters setup correctly. Make sure you have a macro parameter with an Alias of propertyAlias set in your Paramaters tab found in the details of the macro that drives the above XSLT file. 

    Your script looks valid otherwise...

    HTH,
    Nik

Please Sign in or register to post replies

Write your reply to:

Draft