【问题标题】:Tridion RTF IssueTridion RTF 问题
【发布时间】:2017-07-05 02:00:13
【问题描述】:

我们的要求:-

  1. 在 RTF 字段中插入图片时,我们需要从中删除内联样式和标题文本。

  2. alt 文本应该是图像的名称。

下面是实现,

在架构级别我遵循以下步骤,

  1. 点击“编辑格式功能”
  2. 在打开的弹出窗口中转到“过滤 XSLT”选项卡
  3. 在下面写代码段:

在模式级别添加以下 XSLT 代码后测试富文本字段期间:

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

我们发现了以下问题:

  1. 在初始加载期间(当使用项目选择器选择图像时)HTML 使用选择图像 tcm id 及其在 alt 属性中的标题正确呈现。
  2. 但是如果我们在 RTF 字段中修改或写入任何内容,那么 alt 属性就会变为空白。

例如:

&lt;img src="tcm:8-125-8" alt="testimage"/&gt; [在初始加载期间]

&lt;img src="tcm:8-125-8" alt=""/&gt; [对 RTF 进行任何更改后]

我正在使用 Tridion 2013。

【问题讨论】:

  • 以上 xslt 代码是针对架构级别的每个 rtf 字段编写的。
  • 我当然建议在专门的 Tridion Stack Exchange 网站 tridion.stackexchange.com 上提出这个问题

标签: xslt rtf tridion


【解决方案1】:

我终于找到了解决办法,

这里有一些代码更改需要避免问题,

<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>

谢谢.. 问候, 合金

【讨论】:

    猜你喜欢
    • 2012-09-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-12-16
    • 2012-08-06
    相关资源
    最近更新 更多