You can help me fix the poster's avatar.
Nope. Not without an addon. You need to operate on the post message to extract IMG URLs.
Is not it still be possible? Or have a plugin available?
Hi @Jake Bunce - I tried this with thread_view and xenporta articles; using template edits. It still picks up the avatar instead of the the attachment. I'm serving all my images through CDN from url (data.crazyengineers.com) - could that be an issue?
This code is a little ugly. I couldn't find a way to access the first attachment from $firstPost.attachments without using foreach. There may be an easier way, but this code works in my testing. Also... I have since discovered that this code only works on the first page of the thread. Or rather, it pulls the first attachment from the first post on the current page.
I came up with this template edit that sets the thumbnail of the first attachment in the first post as an og:image. Otherwise it will fall back to using the avatar of the thread author which it already does by default.
Edit this template:
Admin CP -> Appearance -> Templates -> thread_view
Replace this code:
Code:<xen:container var="$head.openGraph"><xen:include template="open_graph_meta"> <xen:set var="$url">{xen:link 'canonical:threads', $thread}</xen:set> <xen:set var="$title">{$thread.title}</xen:set> <xen:set var="$avatar">{xen:helper avatar, $thread, m, 0, 1}</xen:set> </xen:include></xen:container>
With this:
Code:<xen:comment>extract first thumbnail URL from first post, for use in open_graph_meta below</xen:comment> <xen:if is="{$firstPost.attachments}"> <xen:foreach loop="$firstPost.attachments" value="$attachment" i="$i" count="$count"> <xen:if is="{$i} == 1 AND {$attachment.thumbnailUrl}"> <xen:set var="$ogThumb">{xen:helper fullurl, $attachment.thumbnailUrl, 1}</xen:set> </xen:if> </xen:foreach> </xen:if> <xen:container var="$head.openGraph"><xen:include template="open_graph_meta"> <xen:set var="$url">{xen:link 'canonical:threads', $thread}</xen:set> <xen:set var="$title">{$thread.title}</xen:set> <xen:set var="$avatar"><xen:if is="{$ogThumb}">{$ogThumb}<xen:else />{xen:helper avatar, $thread, m, 0, 1}</xen:if></xen:set> </xen:include></xen:container>
For referenece:
http://xenforo.com/community/threads/changing-og-image-thumbnail.17141/
This code is a little ugly. I couldn't find a way to access the first attachment from $firstPost.attachments without using foreach. There may be an easier way, but this code works in my testing. Also... I have since discovered that this code only works on the first page of the thread. Or rather, it pulls the first attachment from the first post on the current page.
I came up with this template edit that sets the thumbnail of the first attachment in the first post as an og:image. Otherwise it will fall back to using the avatar of the thread author which it already does by default.
Edit this template:
Admin CP -> Appearance -> Templates -> thread_view
Replace this code:
Code:<xen:container var="$head.openGraph"><xen:include template="open_graph_meta"> <xen:set var="$url">{xen:link 'canonical:threads', $thread}</xen:set> <xen:set var="$title">{$thread.title}</xen:set> <xen:set var="$avatar">{xen:helper avatar, $thread, m, 0, 1}</xen:set> </xen:include></xen:container>
With this:
Code:<xen:comment>extract first thumbnail URL from first post, for use in open_graph_meta below</xen:comment> <xen:if is="{$firstPost.attachments}"> <xen:foreach loop="$firstPost.attachments" value="$attachment" i="$i" count="$count"> <xen:if is="{$i} == 1 AND {$attachment.thumbnailUrl}"> <xen:set var="$ogThumb">{xen:helper fullurl, $attachment.thumbnailUrl, 1}</xen:set> </xen:if> </xen:foreach> </xen:if> <xen:container var="$head.openGraph"><xen:include template="open_graph_meta"> <xen:set var="$url">{xen:link 'canonical:threads', $thread}</xen:set> <xen:set var="$title">{$thread.title}</xen:set> <xen:set var="$avatar"><xen:if is="{$ogThumb}">{$ogThumb}<xen:else />{xen:helper avatar, $thread, m, 0, 1}</xen:if></xen:set> </xen:include></xen:container>
For referenece:
http://xenforo.com/community/threads/changing-og-image-thumbnail.17141/
We use essential cookies to make this site work, and optional cookies to enhance your experience.