Copied to clipboard

Flag this post as spam?

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


  • maarten 10 posts 30 karma points
    Feb 21, 2012 @ 15:01
    maarten
    0

    Adding a class to an image

    So this is what I'm trying to do : I want to add an image with a macro in the richtexteditor. The reason I'm not using the normal Image tool, is because I want to add a class,rel & group attribute to the image, and also an anchor tag. I'm doing it this way so that when you add an image, it automatically will be able to be opened with a fancybox.

    I thought I had everything figured out, it's a pretty simple xslt file, but when I add an image for example "test.jpg", the src attribute of the image is something like this "test.jpg.84894515.jpg". So the image can't be found because of all the extra numbers that are added to the image link.

    Thanks if anyone can help with this.

    I'm using the following macro :

    <?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:variable name="width" select="/macro/width" />
        <xsl:variable name="height" select="/macro/height" />
        <xsl:variable name="imageLink" select="/macro/imageLink" />
    
        <xsl:template match="/">
    
                        <a href="{$imageLink}" class="group" rel="group" id="fancy">
                                    <img src="{$imageLink}" width="{$width}" height="{$height}" alt="{@nodeName}" title="{@nodeName}" />     
                                    </a>
    
        </xsl:template>   
    </xsl:stylesheet>
  • Almir Vereget 62 posts 150 karma points
    Feb 21, 2012 @ 15:28
    Almir Vereget
    0

    Hi,

    try to change your imageLink variable like this:

    <xsl:variablename="imageLink"select="/macro/imageLink/*/umbracoFile"/>
  • maarten 10 posts 30 karma points
    Feb 21, 2012 @ 15:33
    maarten
    0

    Thanks a lot, that worked!

Please Sign in or register to post replies

Write your reply to:

Draft