diff options
| author | Ken D'Ambrosio <ken@jots.org> | 2026-06-16 18:58:34 +0000 |
|---|---|---|
| committer | Ken D'Ambrosio <ken@jots.org> | 2026-06-16 18:58:34 +0000 |
| commit | f2095eeb14db8db6558812225e5a0638d9fc9cd0 (patch) | |
| tree | e90980188a631609e5582b5d4457135241a346bf | |
| parent | a0803c8e87f375b1f138c7d1650ba21108f1cc62 (diff) | |
Fix OG image for photo links: use thumbnail, drop false dimension tags
When ?photo= is in the URL, @og_use_media was forcing the full-res
image (2-3MB) as the og:image. WhatsApp fetched it but showed no
preview, likely due to size or timeout. Now uses the thumbnail.
Also removed hardcoded og:image:width/height (1200x630) from individual
photo/album pages — those dimensions only apply to the default fallback
image and were causing WhatsApp to reject previews when the actual image
dimensions didn't match the declared ones.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
| -rw-r--r-- | app.rb | 1 | ||||
| -rw-r--r-- | views/layout.erb | 5 |
2 files changed, 4 insertions, 2 deletions
@@ -445,7 +445,6 @@ def browse_album(rel) if params[:photo] && !params[:photo].empty? photo_name = File.basename(params[:photo]) @og_image_rel = rel.empty? ? photo_name : "#{rel}/#{photo_name}" - @og_use_media = true elsif !rel.empty? first_img = @entries.find { |e| %i[image video].include?(e[:type]) } @og_image_rel = if first_img diff --git a/views/layout.erb b/views/layout.erb index d02a67a..6a85482 100644 --- a/views/layout.erb +++ b/views/layout.erb @@ -8,9 +8,12 @@ <meta property="og:url" content="<%= request.url %>"> <meta property="og:title" content="<%= ERB::Util.html_escape("#{@title} — Albumen") %>"> <% if @desc %><meta property="og:description" content="<%= ERB::Util.html_escape(@desc) %>"><% end %> - <meta property="og:image" content="<%= og_image_url || "#{request.base_url}/img/og-default.png" %>"> + <% _og_img = og_image_url %> + <meta property="og:image" content="<%= _og_img || "#{request.base_url}/img/og-default.png" %>"> + <% unless _og_img %> <meta property="og:image:width" content="1200"> <meta property="og:image:height" content="630"> + <% end %> <link rel="icon" type="image/x-icon" href="/favicon.ico"> <link rel="apple-touch-icon" href="/apple-touch-icon.png"> <link rel="stylesheet" href="/css/style.css?v=2"> |
