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.
This commit is contained in:
parent
4236e1a81d
commit
371b534c48
@ -5,7 +5,7 @@
|
|||||||
<div class="absolute inset-0">
|
<div class="absolute inset-0">
|
||||||
<% begin %>
|
<% begin %>
|
||||||
<%= image_tag @latest_arts&.first&.webp_image&.processed,
|
<%= 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" %>
|
class: "w-full h-full object-cover" %>
|
||||||
<% rescue StandardError => e %>
|
<% rescue StandardError => e %>
|
||||||
<% Rails.logger.error("图片加载失败: #{e.message}") if defined?(Rails) %>
|
<% Rails.logger.error("图片加载失败: #{e.message}") if defined?(Rails) %>
|
||||||
|
Loading…
Reference in New Issue
Block a user