From 04950054cd37ec5986ec16d5846d89a9f849846b Mon Sep 17 00:00:00 2001 From: Marwin Hochfelsner <50826859+hlfan@users.noreply.github.com> Date: Fri, 3 Apr 2026 13:03:35 +0200 Subject: [PATCH] Deduplicate trace image handling --- app/helpers/trace_helper.rb | 18 ++++++++---------- app/views/traces/feeds/_description.html.erb | 2 +- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/app/helpers/trace_helper.rb b/app/helpers/trace_helper.rb index 3d0704e66..e1902c331 100644 --- a/app/helpers/trace_helper.rb +++ b/app/helpers/trace_helper.rb @@ -1,23 +1,21 @@ # frozen_string_literal: true module TraceHelper + def trace_image(trace, animated: false, only_path: true, **options) + args = [trace.user, trace, { :only_path => only_path }] + src = animated ? trace_picture_url(*args) : trace_icon_url(*args) + image_tag(src, { :class => "trace_image", :alt => "" }.merge(options)) + end + def link_to_tag(tag) link_to(tag, :tag => tag, :page => nil) end def trace_icon(trace, options = {}) - options[:class] ||= "trace_image" - options[:alt] ||= "" - - image_tag trace_icon_path(trace.user, trace), - options.merge(:size => 50) + trace_image(trace, :size => 50, **options) end def trace_picture(trace, options = {}) - options[:class] ||= "trace_image" - options[:alt] ||= "" - - image_tag trace_picture_path(trace.user, trace), - options.merge(:size => 250) + trace_image(trace, :animated => true, :size => 250, **options) end end diff --git a/app/views/traces/feeds/_description.html.erb b/app/views/traces/feeds/_description.html.erb index 20799c854..deaf0045a 100644 --- a/app/views/traces/feeds/_description.html.erb +++ b/app/views/traces/feeds/_description.html.erb @@ -1,6 +1,6 @@ <%# locals: (trace:) %> -<%= image_tag trace_icon_url(trace.user, trace), :alt => "" %> +<%= trace_image(trace, :only_path => false) %> <% if trace.size -%> <%= t ".description_with_count", :count => trace.size, :user => trace.user.display_name %> <% else -%> -- 2.39.5