diff --git a/app/models/weather_art.rb b/app/models/weather_art.rb index 67684e5..e311aeb 100644 --- a/app/models/weather_art.rb +++ b/app/models/weather_art.rb @@ -167,6 +167,10 @@ class WeatherArt < ApplicationRecord ) end + def image_alt + "#{self.city.full_name} Weather Art - #{self.description} at #{self.temperature}°C on #{self.formatted_time(:date)}" + end + private def create_overlay_text diff --git a/app/views/arts/index.html.erb b/app/views/arts/index.html.erb index 466c7aa..6ba4dec 100644 --- a/app/views/arts/index.html.erb +++ b/app/views/arts/index.html.erb @@ -7,9 +7,8 @@ <% if featured_art&.image&.attached? %>
<% begin %> - <% alt_text = "#{art.city.full_name} Weather Art - at #{art.temperature}°C on #{art.formatted_time(:date)}" %> <%= image_tag featured_art.webp_image.processed, - alt: alt_text, + alt: featured_art.image_alt, class: "w-full h-full object-cover" %> <% rescue StandardError => e %> <% Rails.logger.error("image load error: #{e.message}") if defined?(Rails) %> @@ -114,9 +113,8 @@
<% if art.image.attached? %> <% begin %> - <% alt_text = "#{art.city.full_name} Weather Art - at #{art.temperature}°C on #{art.formatted_time(:date)}" %> <%= image_tag art.preview_image.processed, - alt: alt_text, + alt: art.image_alt, class: "w-full h-full object-cover transform group-hover:scale-105 transition-transform duration-500" %> <% rescue StandardError => e %>
diff --git a/app/views/cities/_city.html.erb b/app/views/cities/_city.html.erb index f55851a..45f56ea 100644 --- a/app/views/cities/_city.html.erb +++ b/app/views/cities/_city.html.erb @@ -6,6 +6,7 @@
<%= image_tag city.latest_weather_art.preview_image.processed, + alt: city.latest_weather_art.image_alt, class: "w-full h-full object-cover transform group-hover:scale-105 transition-transform duration-500" %>
diff --git a/app/views/cities/index.html.erb b/app/views/cities/index.html.erb index 7a0f802..445370e 100644 --- a/app/views/cities/index.html.erb +++ b/app/views/cities/index.html.erb @@ -8,6 +8,7 @@ <% begin %>
<%= image_tag featured_art.webp_image.processed, + alt: featured_art.image_alt, class: "w-full h-full object-cover object-center" %> <% rescue StandardError => e %> <% Rails.logger.error("image load error: #{e.message}") if defined?(Rails) %> diff --git a/app/views/cities/show.html.erb b/app/views/cities/show.html.erb index ad8fa12..55b38ba 100644 --- a/app/views/cities/show.html.erb +++ b/app/views/cities/show.html.erb @@ -5,6 +5,7 @@ <% if @city.latest_weather_art&.image&.attached? %>
<%= image_tag @city.latest_weather_art.webp_image.processed, + alt: @city.latest_weather_art.image_alt, class: "w-full h-full object-cover object-center" %>
diff --git a/app/views/devise/shared/_links.html.erb b/app/views/devise/shared/_links.html.erb index dc2663d..669f89a 100644 --- a/app/views/devise/shared/_links.html.erb +++ b/app/views/devise/shared/_links.html.erb @@ -25,7 +25,7 @@

<%= button_to omniauth_authorize_path(resource_name, provider), class: "btn btn-outline w-full gap-2", data: { turbo: false } do %> - <%= image_tag("#{provider}.svg", class: "w-5 h-5") if File.exist?(Rails.root.join("app/assets/images/#{provider}.svg")) %> + <%= image_tag("#{provider}.svg", alt: "#{provider}", class: "w-5 h-5") if File.exist?(Rails.root.join("app/assets/images/#{provider}.svg")) %> Sign in with <%= OmniAuth::Utils.camelize(provider) %>

<% end %> <% end %> diff --git a/app/views/home/_arts.html.erb b/app/views/home/_arts.html.erb index 840a6bc..b14a176 100644 --- a/app/views/home/_arts.html.erb +++ b/app/views/home/_arts.html.erb @@ -4,7 +4,9 @@
<% if art.image.attached? %> <% begin %> - <%= image_tag art.preview_image&.processed, class: "w-full h-full object-cover transform hover:scale-105 transition-transform duration-500" %> + <%= image_tag art.preview_image&.processed, + alt: art.image_alt, + class: "w-full h-full object-cover transform hover:scale-105 transition-transform duration-500" %> <% rescue StandardError => e %>
diff --git a/app/views/home/index.html.erb b/app/views/home/index.html.erb index 8a79f96..2a0647c 100644 --- a/app/views/home/index.html.erb +++ b/app/views/home/index.html.erb @@ -4,7 +4,9 @@ <% if @latest_arts.first&.image&.attached? %>
<% begin %> - <%= image_tag @latest_arts&.first&.webp_image&.processed, class: "w-full h-full object-cover" %> + <%= image_tag @latest_arts&.first&.webp_image&.processed, + alt: @latest_arts.image_alt, + class: "w-full h-full object-cover" %> <% rescue StandardError => e %> <% Rails.logger.error("图片加载失败: #{e.message}") if defined?(Rails) %> <% end %> diff --git a/app/views/weather_arts/_card.html.erb b/app/views/weather_arts/_card.html.erb index ac0743f..068dff2 100644 --- a/app/views/weather_arts/_card.html.erb +++ b/app/views/weather_arts/_card.html.erb @@ -3,6 +3,7 @@
<% if weather_art.image.attached? %> <%= image_tag weather_art.preview_image.processed, + alt: weather_art.image_alt, class: "w-full h-full object-cover transform hover:scale-105 transition-transform duration-500" %>
diff --git a/app/views/weather_arts/show.html.erb b/app/views/weather_arts/show.html.erb index 7491dda..c01666b 100644 --- a/app/views/weather_arts/show.html.erb +++ b/app/views/weather_arts/show.html.erb @@ -46,7 +46,6 @@