From addf2d6cc593464db2160011029dbeee8b3478b9 Mon Sep 17 00:00:00 2001 From: Emi Matchu Date: Sat, 7 Dec 2024 11:45:01 -0800 Subject: [PATCH] Use SVG for the magnified outfit viewer when editing pet appearance --- app/helpers/outfits_helper.rb | 6 ++++-- app/views/application/_outfit_viewer.html.haml | 4 +++- app/views/pet_states/_support_outfit_viewer.html.haml | 3 ++- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/app/helpers/outfits_helper.rb b/app/helpers/outfits_helper.rb index d130213d..a31d8587 100644 --- a/app/helpers/outfits_helper.rb +++ b/app/helpers/outfits_helper.rb @@ -77,13 +77,15 @@ module OutfitsHelper private - def parse_outfit_viewer_options(outfit=nil, pet_state: nil, **html_options) + def parse_outfit_viewer_options( + outfit=nil, pet_state: nil, preferred_image_format: :png, **html_options + ) outfit = Outfit.new(pet_state:) if outfit.nil? && pet_state.present? if outfit.nil? raise ArgumentError, "outfit viewer must have outfit or pet state" end - {outfit:, html_options:} + {outfit:, preferred_image_format:, html_options:} end end diff --git a/app/views/application/_outfit_viewer.html.haml b/app/views/application/_outfit_viewer.html.haml index c18acc4c..52f2e386 100644 --- a/app/views/application/_outfit_viewer.html.haml +++ b/app/views/application/_outfit_viewer.html.haml @@ -21,7 +21,9 @@ } - if swf_asset.canvas_movie? %iframe{src: swf_asset_path(swf_asset, playing: outfit_viewer_is_playing ? true : nil)} - - elsif swf_asset.image_url.present? + - elsif preferred_image_format == :svg && swf_asset.svg_url? + = image_tag swf_asset.svg_url, alt: "", loading: "lazy" + - elsif swf_asset.image_url? = image_tag swf_asset.image_url, alt: "", loading: "lazy" - else / No movie or image available for SWF asset: #{swf_asset.url} diff --git a/app/views/pet_states/_support_outfit_viewer.html.haml b/app/views/pet_states/_support_outfit_viewer.html.haml index 9bcb935e..fd403e44 100644 --- a/app/views/pet_states/_support_outfit_viewer.html.haml +++ b/app/views/pet_states/_support_outfit_viewer.html.haml @@ -1,6 +1,7 @@ = content_tag "support-outfit-viewer", **html_options do + -# Render an outfit viewer in a magnifier. Use SVG for maximum clarity! %magic-magnifier - = outfit_viewer outfit + = outfit_viewer outfit, preferred_image_format: :svg %table %thead