diff --git a/app/models/picture.rb b/app/models/picture.rb
index bb98a115..6573a97b 100644
--- a/app/models/picture.rb
+++ b/app/models/picture.rb
@@ -5,6 +5,10 @@ class Picture < ApplicationRecord
attachable.variant :large, resize_to_limit: [ 1500, 1500 ]
end
+ def large_image
+ image.variable? ? image.variant(:large) : image
+ end
+
def markable
caption
end
diff --git a/app/views/leafables/show.html.erb b/app/views/leafables/show.html.erb
index 99d0af3c..bc64e1bc 100644
--- a/app/views/leafables/show.html.erb
+++ b/app/views/leafables/show.html.erb
@@ -27,7 +27,7 @@
action: "lightbox#open:prevent",
lightbox_target: "image",
lightbox_url_value: rails_blob_path(@leaf.picture.image, disposition: "attachment", only_path: true) } do %>
- <%= image_tag @leaf.picture.image.variant(:large), loading: "lazy" %>
+ <%= image_tag @leaf.picture.large_image, loading: "lazy" %>
<% end %>
<% else %>
<%= image_tag "default-picture.webp", alt: "No image uploaded", loading: "lazy" %>
diff --git a/app/views/leaves/_edit.html.erb b/app/views/leaves/_edit.html.erb
index 43633f58..559939d5 100644
--- a/app/views/leaves/_edit.html.erb
+++ b/app/views/leaves/_edit.html.erb
@@ -7,7 +7,7 @@
<%= link_to leafable_path(leaf), class: "toc__thumbnail", data: { turbo_frame: "_top" } do %>
<%= leaf.section.body if leaf.section? %>
<%= sanitize_content(leaf.leafable.body.to_html) if leaf.page? %>
- <%= image_tag leaf.leafable.image.variant(:large) if leaf.picture&.image&.attached? %>
+ <%= image_tag leaf.leafable.large_image if leaf.picture&.image&.attached? %>
<% end %>
diff --git a/app/views/leaves/_leaf.html.erb b/app/views/leaves/_leaf.html.erb
index dccdd672..e6282542 100644
--- a/app/views/leaves/_leaf.html.erb
+++ b/app/views/leaves/_leaf.html.erb
@@ -27,7 +27,7 @@
<%= sanitize_content leaf.page.html_preview if leaf.page? %>
<% if leaf.picture? %>
- <%= image_tag leaf.leafable.image.attached? ? leaf.leafable.image.variant(:large) : "default-picture.webp" %>
+ <%= image_tag leaf.leafable.image.attached? ? leaf.leafable.large_image : "default-picture.webp" %>
<% end %>
diff --git a/app/views/pictures/_form.html.erb b/app/views/pictures/_form.html.erb
index da1b4948..1805eb72 100644
--- a/app/views/pictures/_form.html.erb
+++ b/app/views/pictures/_form.html.erb
@@ -1,6 +1,6 @@
<%= leafable_edit_form(picture, id: "leafable-editor") do |form| %>