Thêm ảnh đại diện khi chia sẻ lên Facebook
Mở template thread_view, tìm code sau:
Thay thế thành:
Here's how to create og:image tag by finding the file in the post, and automatically selecting the largest image file size.
Mở template thread_view, tìm code sau:
XML:
<xf:macro template="metadata_macros" name="metadata"
arg-description="{$fpSnippet}"
arg-shareUrl="{{ link('canonical:threads', $thread) }}"
arg-canonicalUrl="{{ link('canonical:threads', $thread, {'page': $page}) }}" />
Thay thế thành:
XML:
<xf:set var="$og_image" value="0" />
<xf:set var="$file_size" value="0" />
<xf:foreach loop="$thread.FirstPost.Attachments" value="$attach">
<xf:if is="$attach.thumbnail_url && ($attach.file_size > $file_size)">
<xf:set var="$og_image" value="{{ link('canonical:attachments', $attach) }}" />
<xf:set var="$file_size" value="{$attach.file_size}" />
</xf:if>
</xf:foreach>
<xf:if is="$og_image">
<xf:macro template="metadata_macros" name="metadata"
arg-imageUrl="{$og_image}"
arg-description="{$fpSnippet}"
arg-shareUrl="{{ link('canonical:threads', $thread) }}"
arg-canonicalUrl="{{ link('canonical:threads', $thread, {'page': $page}) }}" />
<xf:else/>
<xf:macro template="metadata_macros" name="metadata"
arg-description="{$fpSnippet}"
arg-shareUrl="{{ link('canonical:threads', $thread) }}"
arg-canonicalUrl="{{ link('canonical:threads', $thread, {'page': $page}) }}" />
</xf:if>
Here's how to create og:image tag by finding the file in the post, and automatically selecting the largest image file size.