Tridion RTF Issue

109 Views Asked by At

Our Requirement :-

  1. While inserting image in RTF field we need to remove inline style and Title text from it.

  2. alt text should be the name of the Image.

Below is the implementation,

In schema level I followed below steps,

  1. Click on “Edit Formatting Feature”
  2. Go to “Filtering XSLT” tab on opened pop up
  3. Write below code segment:

During testing the rich text field after adding below XSLT code in schema level:

<xsl:template match="img">
    <img src="{@src}" alt="{@title}"/>
</xsl:template>

We identified below issues:

  1. During initial load (when Image is selected using item selector) HTML is rendered properly with select image tcm id and its title in alt attribute.
  2. But if we modify or write anything in RTF field then alt attribute become blank.

For example :

<img src="tcm:8-125-8" alt="testimage"/> [during initial load]

<img src="tcm:8-125-8" alt=""/> [After doing any changes in RTF]

I'm using Tridion 2013.

1

There are 1 best solutions below

0
Aloy Banerjee On

I finally found out the solution for doing so,

here are some code changes require for avoiding problem,

<xsl:template match="img">
        <xsl:element name="img">
            <xsl:attribute name="src">
                <xsl:value-of select="@src"></xsl:value-of>
            </xsl:attribute>
            <xsl:attribute name="alt">
                <xsl:value-of select="@alt"></xsl:value-of>
            </xsl:attribute>
        </xsl:element>
    </xsl:template>

Thanks.. Regards, Aloy