What's new

Welcome to XFWORLD.NET

Join us now to get access to all our features. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, and so, so much more. It's also quick and totally free, so what are you waiting for?

XF 2.2 [JoyFreak] Set Open Graph Image

Maldinor

Maldinor

Site Owner
Staff member
Administrator
Moderator
IPS Coder
xenForo Coder
Joined
Sep 11, 2019
Messages
7,291
Reaction score
1,736
Points
246
Location
UK
Website
xfworld.net
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:
Code:
<xf:set var="$fpSnippet" value="{{ snippet($firstPost.message, 0, {'stripBbCode': true}) }}" />

Add below:
Code:
<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:
Code:
arg-canonicalUrl="{{ link('canonical:threads', $thread, {'page': $page}) }}" />

Add below:
Code:
</xf:if>

Save.
 

Similar threads

Top Bottom