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