Help Forum của em không có mục add ảnh thumbnail

gameboiz1806

Private
Tham gia
15/11/2023
Bài viết
49
Được Like
4
Chào mọi người,
Hiện tại em muốn thêm ảnh thumbnail vào các article của em nhưng khi đăng em thấy không có mục add ảnh thumbnail. Em cần làm gì ạ? Em muốn dùng thumbnail để share post lên Facebook ạ.Em cảm ơn ạ
 

PhuongBinzz

Moderator
Thành viên BQT
Tham gia
21/07/2016
Bài viết
1,193
Được Like
442
Cách tạo thẻ OG:IMAGE cho bài viết XenForo 2

Bài viết này sẽ hướng dẫn các bạn cách tạo thẻ og:image thông minh bằng cách tìm tập tin trong bài viết và tự động lựa chọn tập tin hình ảnh có kích thước lớn nhất làm thẻ og:image. Cách làm như sau:

Mở template thread_view, tìm đoạn code sau:
Mã:
<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 bằng:

Mã:
<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>

Lưu lại là xong.

Chúc các bạn thành công.
 

gameboiz1806

Private
Tham gia
15/11/2023
Bài viết
49
Được Like
4
Cách tạo thẻ OG:IMAGE cho bài viết XenForo 2

Bài viết này sẽ hướng dẫn các bạn cách tạo thẻ og:image thông minh bằng cách tìm tập tin trong bài viết và tự động lựa chọn tập tin hình ảnh có kích thước lớn nhất làm thẻ og:image. Cách làm như sau:

Mở template thread_view, tìm đoạn code sau:
Mã:
<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 bằng:

Mã:
<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>

Lưu lại là xong.

Chúc các bạn thành công.
Em có vừa làm như này nhưng mà khi em share lên Facebook, ảnh thumbnail nó vẫn chỉ hiện là Logo của site anh ạ
 

PhuongBinzz

Moderator
Thành viên BQT
Tham gia
21/07/2016
Bài viết
1,193
Được Like
442
Em có vừa làm như này nhưng mà khi em share lên Facebook, ảnh thumbnail nó vẫn chỉ hiện là Logo của site anh ạ
để test share link vào : https://developers.facebook.com/tools/debug/

trường hợp có bản share trước đó "thu thập lại" để có chính xác nhé



1700112762307.png
 

Hướng dẫn sử dụng

XenForo 1 XenForo 2
Translate by PVS

Dịch vụ XenForo của VNXF

Mobile/Zalo: 0906081284

Telegram: anhanhxf

Chỉ nhận web nội dung lành mạnh

Nhà Tài Trợ

Mút Xốp Không Gian
Mút Sofa Không Gian
Top Bottom