[JoyFreak] Set Open Graph Image

[JoyFreak] Set Open Graph Image 2022-11-24

没有下载权限
XF 兼容性
  1. 2.2.x
摘要
A step-by-step guide to setting your forum's open graph image using the first thread image. Add a conditional macro for cover images and include canonical URLs in Open Graph metadata for better SEO. Example provided for Gaming Forum.
This guide will help you to set your forum's open graph image. It will use the first image in your thread, whether linked directly or attached.

Open template: thread_view

Find:
代码:
<xf:set var="$fpSnippet" value="{{ snippet($firstPost.message, 0, {'stripBbCode': true}) }}" />


Add below:

HTML:
<xf:if is="$thread.cover_image">
<xf:macro template="metadata_macros" name="metadata"
    arg-description="{$fpSnippet}"
    arg-shareUrl="{{ link('canonical:threads', $thread) }}"
    arg-canonicalUrl="{{ link('canonical:threads', $thread, {'page': $page}) }}"
    arg-imageUrl="{$thread.cover_image}" />
<xf:else/>


Find:
代码:
arg-canonicalUrl="{{ link('canonical:threads', $thread, {'page': $page}) }}" />


Add below:
代码:
</xf:if>


Save.

Example at Gaming Forum
作者
axtona
浏览
460
首次发布
上次更新
评分 0.00 星 0 个评分
链接失效了吗? 发送消息 给 NP 团队,我们会尽快为您处理!
支持开发者 如果您对测试满意或项目已成功盈利,可点击「更多信息」按钮,通过购买来支持开发者!

来自 axtona 的更多资源

巫师PRO A
巫师PRO 13.1.1
将PHP和任何类型的HTML、CSS和JavaScript代码直接放入内容中!
清理大师PRO A
缓存清理程序还可以在您保存文章或其他项目时自动清除Joomla! 缓存。
自动关闭 + 留言通知 A
自动关闭讨论提醒有助于保持较旧的讨论整洁,而不让您的成员感到意外。

相似的资源

[cXF] Node icons with image A
Would you like to change your default Font Awesome node icons with image like this?
Default image for trending threads H
modification trending threads without image will have an image by default.
返回
顶部