From 5e908e40f68e97606a908854d793b1d2bf253775 Mon Sep 17 00:00:00 2001 From: "byte[]" Date: Mon, 10 Apr 2023 21:33:44 -0400 Subject: [PATCH] Fix markdown embed displays for small images --- lib/philomena_web/markdown_renderer.ex | 3 +++ lib/philomena_web/templates/image/_image_page.html.slime | 2 +- lib/philomena_web/templates/image/_image_target.html.slime | 3 ++- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/philomena_web/markdown_renderer.ex b/lib/philomena_web/markdown_renderer.ex index 8890335a..8e96982c 100644 --- a/lib/philomena_web/markdown_renderer.ex +++ b/lib/philomena_web/markdown_renderer.ex @@ -80,6 +80,7 @@ defmodule PhilomenaWeb.MarkdownRenderer do case group do [_id, "p"] when not img.hidden_from_users and img.approved -> Phoenix.View.render(@image_view, "_image_target.html", + embed_display: true, image: img, size: @image_view.select_version(img, :medium), conn: conn @@ -88,6 +89,7 @@ defmodule PhilomenaWeb.MarkdownRenderer do [_id, "t"] when not img.hidden_from_users and img.approved -> Phoenix.View.render(@image_view, "_image_target.html", + embed_display: true, image: img, size: @image_view.select_version(img, :small), conn: conn @@ -96,6 +98,7 @@ defmodule PhilomenaWeb.MarkdownRenderer do [_id, "s"] when not img.hidden_from_users and img.approved -> Phoenix.View.render(@image_view, "_image_target.html", + embed_display: true, image: img, size: @image_view.select_version(img, :thumb_small), conn: conn diff --git a/lib/philomena_web/templates/image/_image_page.html.slime b/lib/philomena_web/templates/image/_image_page.html.slime index 8c7bb815..1100694a 100644 --- a/lib/philomena_web/templates/image/_image_page.html.slime +++ b/lib/philomena_web/templates/image/_image_page.html.slime @@ -1,6 +1,6 @@ .center--layout--flex = if @image.thumbnails_generated do - = render PhilomenaWeb.ImageView, "_image_target.html", image: @image, conn: @conn + = render PhilomenaWeb.ImageView, "_image_target.html", embed_display: false, image: @image, conn: @conn - else #thumbnails-not-yet-generated.block.block--fixed.block--warning.layout--narrow h3 Just a moment diff --git a/lib/philomena_web/templates/image/_image_target.html.slime b/lib/philomena_web/templates/image/_image_target.html.slime index f38526b6..45315404 100644 --- a/lib/philomena_web/templates/image/_image_target.html.slime +++ b/lib/philomena_web/templates/image/_image_target.html.slime @@ -1,4 +1,5 @@ - size = assigns[:size] || :full +- embed_display = assigns[:embed_display] || false = content_tag :div, [data: image_container_data(@conn, @image, size), class: "image-show-container"] do .block.block--fixed.block--warning.block--no-margin.image-filtered.hidden @@ -10,7 +11,7 @@ =< link("your current filter", to: Routes.filter_path(@conn, :show, @conn.assigns.current_filter), class: "filter-link") ' . - = if size == :full do + = if size == :full and not embed_display do .image-target.hidden.image-show data-scaled=scaled_value(@conn.assigns.current_user) data-uris=Jason.encode!(thumb_urls(@image, can?(@conn, :hide, @image))) data-width=@image.image_width data-height=@image.image_height data-image-size=@image.image_size data-mime-type=@image.image_mime_type = if @image.image_mime_type == "video/webm" do video controls=true