From 371b534c484d3f4f6216e674d62ce8631cff11e0 Mon Sep 17 00:00:00 2001 From: songtianlun Date: Thu, 10 Apr 2025 22:47:33 +0800 Subject: [PATCH] fix: correct alt attribute for image tag - Update alt attribute to reference the first item's image_alt - This change improves accessibility by ensuring the correct descriptive text is used if the latest_arts is present. Prior to this change, there was a risk of displaying an incorrect description if the latest_arts was empty, which could lead to confusion for users relying on alt text for context. --- app/views/home/index.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/home/index.html.erb b/app/views/home/index.html.erb index 2a0647c..67efbc3 100644 --- a/app/views/home/index.html.erb +++ b/app/views/home/index.html.erb @@ -5,7 +5,7 @@
<% begin %> <%= image_tag @latest_arts&.first&.webp_image&.processed, - alt: @latest_arts.image_alt, + alt: @latest_arts&.first&.image_alt, class: "w-full h-full object-cover" %> <% rescue StandardError => e %> <% Rails.logger.error("图片加载失败: #{e.message}") if defined?(Rails) %>