discourse/app/views/users/show.html.erb
Régis Hanol 55e992f507
FIX: add og:image:width and og:image:height to OpenGraph tags (#37849)
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
2026-02-16 20:30:26 +01:00

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 %>