From 22ae32639eacf3a2934ae24b2dc66e5728f3ea7a Mon Sep 17 00:00:00 2001 From: Morgan Roderick Date: Fri, 20 Feb 2026 22:14:40 +0100 Subject: [PATCH] fix(social): add image dimensions and alt text to Open Graph tags - Add og:image:width (1200) and og:image:height (630) for proper preview - Add og:image:alt for accessibility - Fix nil error when workshop has no host --- app/views/shared/_meta_tags.html.haml | 3 +++ app/views/workshops/_meta_tags.html.haml | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/app/views/shared/_meta_tags.html.haml b/app/views/shared/_meta_tags.html.haml index 960153c1c..74741006e 100644 --- a/app/views/shared/_meta_tags.html.haml +++ b/app/views/shared/_meta_tags.html.haml @@ -2,6 +2,9 @@ %meta{ property: 'og:type', content: 'website' } %meta{ property: 'og:url', content: request.original_url } %meta{ property: 'og:image', content: image_url('codebar-social.jpg') } +%meta{ property: 'og:image:width', content: '1200' } +%meta{ property: 'og:image:height', content: '630' } +%meta{ property: 'og:image:alt', content: 'codebar - making tech more diverse and welcoming' } %meta{ property: 'og:description', content: 'Making tech more diverse and welcoming by bringing people together and helping teach programming skills.' } %meta{ property: 'og:site_name', content: 'codebar' } %meta{ property: 'og:locale', content: 'en_GB' } diff --git a/app/views/workshops/_meta_tags.html.haml b/app/views/workshops/_meta_tags.html.haml index cdf5615b5..1cfe2fa37 100644 --- a/app/views/workshops/_meta_tags.html.haml +++ b/app/views/workshops/_meta_tags.html.haml @@ -2,7 +2,7 @@ title = if workshop.virtual? t('workshops.virtual.title_with_date', chapter: workshop.chapter.name, date: humanize_date(workshop.date_and_time)) else - t('workshop.title', host: workshop.host.name, date: humanize_date(workshop.date_and_time)) + t('workshop.title', host: workshop.host&.name || 'codebar', date: humanize_date(workshop.date_and_time)) end url = request.original_url image = workshop.host.try(:image_url).presence || image_url('codebar-social.jpg')