Copied to clipboard

Flag this post as spam?

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


  • Wade 43 posts 159 karma points
    Nov 05, 2009 @ 23:49
    Wade
    0

    Add a default image <AltImage> using an xslt file

    I am trying to add a default image for a person profile to an xslt file (ie: if the team member doesn't have a photo a default avatar silhouette appears).  I want this default image to replace the Hello World! image that appears.   I'm assuming that the post "possible to change the hello, world! image" in this forum would discuss how to do this, but unfortunately all I get when I try to read that particular forum is the following "Error parsing XSLT file: \xslt\forum-commentsList.xslt".  

    The xslt code is as follows:

    <?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" 
        exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets ">
    
    
    <xsl:output method="xml" omit-xml-declaration="yes" />
    
    <xsl:param name="currentPage"/>
    
    <xsl:template match="/">
    
    <!-- The fun starts here --><div class="personholder">
    <xsl:for-each select="$currentPage/descendant::node [string(data [@alias='umbracoNaviHide']) != '1']">
    <div class="personmain">
        <div class="personleft">
               <div class="personpicmain">
                                  <div class="personpicholder">
                    <div class="personpic1">
                    <img>
                     <xsl:attribute name="src"> 
                     <xsl:text>/umbraco/ImageGen.ashx?image=</xsl:text>
                     <xsl:value-of select="data [@alias = 'personImageMain']"/>
                     <xsl:text>&amp;width=202</xsl:text>
                     <xsl:text>&amp;height=224</xsl:text>
                     <xsl:text>&amp;constrain=true</xsl:text>
                     <xsl:text>&amp;AltImage="../images/silhouette.jpg"</xsl:text>
                     </xsl:attribute>
                    </img>
                            </div>
                      <div class="personpicholder2">
                                    <div class="personpic2"><img><xsl:attribute name="src">/umbraco/ImageGen.aspx?image=<xsl:value-of select="data [@alias = 'personImage2']"/>&amp;width=101&amp;height=112&amp;crop=resize</xsl:attribute>
                        </img>
                                    </div>
                                    <div class="personpic3"><img><xsl:attribute name="src">/umbraco/ImageGen.aspx?image=<xsl:value-of select="data [@alias = 'personImage3']"/>&amp;width=101&amp;height=112&amp;crop=resize</xsl:attribute>
                        </img>
                                    </div>
                                  </div>
                                  </div>
               </div>
                                    <div class="personexp">
                                  <div class="personheader2"><b>Favourite Projects</b></div>
                      <xsl:value-of select="data [@alias = 'personFavouriteProjects']" disable-output-escaping="yes" />
                                  <div class="personheader2"><b>Inspiration for work</b></div>
                        <xsl:value-of select="data [@alias = 'personInspiration']" disable-output-escaping="yes" />
                                  <div class="personheader2"><b>What spins my wheels</b></div>
                        <xsl:value-of select="data [@alias = 'personSpinsWheels']" disable-output-escaping="yes" />
                                  <div class="personheader2"><b>Ideal day out of the office</b></div>
                        <xsl:value-of select="data [@alias = 'personOutOfOffice']" disable-output-escaping="yes" />
                        </div>
                </div>
    
                              <div class="personright">
                                <div class="personheader"><h6><a name="{data [@alias = 'personName']}"><xsl:value-of select="data [@alias = 'personName']"/></a></h6>
                            </div>
                                <div class="personheader2"><b><xsl:value-of select="data [@alias = 'jobTitle']"/></b>
                            </div>
                                <div class="personheader2"><b>Key Roles</b></div>
                    <xsl:value-of select="data [@alias = 'personKeyRoles']" disable-output-escaping="yes" />
                                <div class="personheader2"><b>Specialist Expertise</b></div>
                    <xsl:value-of select="data [@alias = 'personSpecialistExpertise']" disable-output-escaping="yes" />
                    </div>
    
    
    
    
    </div>
    </xsl:for-each>
    </div>
    
    </xsl:template>
    
    </xsl:stylesheet>
    

    The piece of code for the <AltImage> doesn't seem to be working.  

    <xsl:text>&amp;AltImage="../images/silhouette.jpg"</xsl:text>

    It can't find the image, and only displays the can't find image icon rather than the Hello World, so it seems to have recognised something.



  • Wade 43 posts 159 karma points
    Nov 05, 2009 @ 23:59
    Wade
    1

    Sorry everyone, I found the answer after playing around with the code. In xslt to call in an image apparently you don't need " " around the image path.  I simply changed the code to <xsl:text>&amp;AltImage=/images/silhouette.jpg</xsl:text> and it worked perfectly.  

Please Sign in or register to post replies

Write your reply to:

Draft