mirror of
https://gh.wpcy.net/https://github.com/discourse/discourse.git
synced 2026-04-30 02:34:00 +08:00
Facebook's crawler requires image dimension metadata to reliably display image previews when Discourse links are shared. Currently, we only emit `og:image` without the structured dimension properties, which causes Facebook (and other consumers) to skip the image in share previews. This adds `og:image:width` and `og:image:height` meta tags for topic pages by exposing the image upload's dimensions through TopicView and passing them to `crawlable_meta_data`. The dimensions are only emitted when both width and height are available on the upload record. https://meta.discourse.org/t/395484
20 lines
832 B
Text
20 lines
832 B
Text
<div class="user-crawler">
|
|
<img src='<%= ::UrlHelper.local_cdn_url(get_absolute_image_url(@user.small_avatar_url)) %>' alt='<%= @user.username %>' title='<%= @user.username %>' />
|
|
<h2 class='username'><%= @user.username %></h2>
|
|
</div>
|
|
|
|
<% unless @restrict_fields %>
|
|
<p><%= raw @user.user_profile.bio_processed %></p>
|
|
<% end %>
|
|
|
|
<% content_for :head do %>
|
|
<% if @restrict_fields %>
|
|
<%= raw crawlable_meta_data(title: @user.username, image: @user.small_avatar_url, image_width: 45, image_height: 45) %>
|
|
<% else %>
|
|
<%= raw crawlable_meta_data(title: @user.username, description: @user.user_profile.bio_summary, image: @user.small_avatar_url, image_width: 45, image_height: 45) %>
|
|
<% end %>
|
|
<% end %>
|
|
|
|
<% content_for :title do %>
|
|
<%= t("js.user.profile")%> - <%= @user.username %> - <%= SiteSetting.title %>
|
|
<% end %>
|