TYPO3 RTE 将 <img> 转换为 <amp-img>
TYPO3 RTE convert <img> to <amp-img>
我有一个 TYPO3 版本 6.2 网站,我正在开发 AMP 版本。
我使用 URL 中的条件加载同一 TYPO3 页面的不同版本,具体取决于页面版本请求是否为 AMP。
普通版页面:
页面的 AMP 版本
一切正常,除非我的页面包含插入 RTE 的图像
在这种情况下,当要求的版本是 AMP 时,我需要将 <img>
转换为 <amp-img>
,以便在 RTE 中插入图像。
我已经有一个全局变量条件来在调用 AMP 版本时加载自定义 TS。
但不知道如何将 <img>
转换为 <amp-img>
关于如何实现这一目标的任何想法?
也许这可以通过扩展 "Content Replacer"、https://extensions.typo3.org/extension/replacer
来实现
如果它只是标签名称的替换,您可以尝试在这些级别之一上使用(有条件的)字符串替换:
整个页面。
你可以做一个stdWrap.replacement
,但这可能不适用于缓存内容
页面内容流畅。
只需使用 viewhelper 来替换呈现内容的文本。甚至可能是错别字 VH:
(<f:cObject typoscriptObjectPath="lib.img2ampimg">{content}</f:cObject>
)
页面内容打字错误。
取决于您是否使用 TS 呈现您的内容,您可以在其中添加 stdWrap.replacement
:
.
page {
10 = FLUIDTEMPLATE
10 {
:
variables {
content < styles.content.get
:
}
}
}
[--your amp condition--]
page.10.variables.content.stdWrap.replacement {
1.search = <img
2.replace = <amp-img
}
[global]
我已经按照 Bernd Wilke 的建议解决了它,但是直接在我的流体模板中:
<f:if condition="{f:cObject(typoscriptObjectPath:'lib.conditionamp')} == 1">
<f:then>
<v:format.replace substring="<img " replacement="<amp-img layout=\"responsive\"">
<f:format.html>{article.corpsDeTexte}</f:format.html>
</v:format.replace>
</f:then>
<f:else>
<f:format.html>{article.corpsDeTexte}</f:format.html>
</f:else>
</f:if>
再次感谢您的帮助
:)
我有一个 TYPO3 版本 6.2 网站,我正在开发 AMP 版本。
我使用 URL 中的条件加载同一 TYPO3 页面的不同版本,具体取决于页面版本请求是否为 AMP。
普通版页面:
页面的 AMP 版本
一切正常,除非我的页面包含插入 RTE 的图像
在这种情况下,当要求的版本是 AMP 时,我需要将 <img>
转换为 <amp-img>
,以便在 RTE 中插入图像。
我已经有一个全局变量条件来在调用 AMP 版本时加载自定义 TS。
但不知道如何将 <img>
转换为 <amp-img>
关于如何实现这一目标的任何想法?
也许这可以通过扩展 "Content Replacer"、https://extensions.typo3.org/extension/replacer
来实现如果它只是标签名称的替换,您可以尝试在这些级别之一上使用(有条件的)字符串替换:
整个页面。
你可以做一个stdWrap.replacement
,但这可能不适用于缓存内容页面内容流畅。
只需使用 viewhelper 来替换呈现内容的文本。甚至可能是错别字 VH:
(<f:cObject typoscriptObjectPath="lib.img2ampimg">{content}</f:cObject>
)页面内容打字错误。
取决于您是否使用 TS 呈现您的内容,您可以在其中添加stdWrap.replacement
:
.
page {
10 = FLUIDTEMPLATE
10 {
:
variables {
content < styles.content.get
:
}
}
}
[--your amp condition--]
page.10.variables.content.stdWrap.replacement {
1.search = <img
2.replace = <amp-img
}
[global]
我已经按照 Bernd Wilke 的建议解决了它,但是直接在我的流体模板中:
<f:if condition="{f:cObject(typoscriptObjectPath:'lib.conditionamp')} == 1">
<f:then>
<v:format.replace substring="<img " replacement="<amp-img layout=\"responsive\"">
<f:format.html>{article.corpsDeTexte}</f:format.html>
</v:format.replace>
</f:then>
<f:else>
<f:format.html>{article.corpsDeTexte}</f:format.html>
</f:else>
</f:if>
再次感谢您的帮助 :)