From c14683fe37fabe06082f43e8bf67debc4cca7297 Mon Sep 17 00:00:00 2001 From: erdgeist Date: Tue, 21 Jul 2026 14:24:59 +0200 Subject: Render asset credit inside the gallery lightbox correctly GLightbox's own selector-based description feature never actually resolved a selector in three different attempts -- literal text, then a resolved-but-empty div, then apparently not firing at all against the installed (unversioned) build. Replaced with a small afterSlideLoad handler that reads a plain data-credit-selector attribute and copies the real element's HTML into the slide's description area directly, depending only on GLightbox handing back a real DOM node per slide -- a much smaller contract than trusting its own caption-resolution feature. Renamed the credit div's class from glightbox-desc, since that name is reserved by the library's own bundled CSS (display: none !important) and can't be reliably overridden from here. Also: distinguishes the credit line and the "N Bilder" caption from ordinary body text (italic, muted, matching .author_and_date's existing convention), and makes the lightbox's caption card follow the site's light/dark toggle via Canvas/CanvasText, since the library's bundled theme never adapts to it on its own. --- app/views/content/_asset_credits.html.erb | 6 ++---- app/views/content/_headline_image.html.erb | 15 +++++++++------ 2 files changed, 11 insertions(+), 10 deletions(-) (limited to 'app/views/content') diff --git a/app/views/content/_asset_credits.html.erb b/app/views/content/_asset_credits.html.erb index 85739d09..5959abd1 100644 --- a/app/views/content/_asset_credits.html.erb +++ b/app/views/content/_asset_credits.html.erb @@ -1,11 +1,9 @@ <% if @page.assets.images.any? %>
<% @page.assets.images.each do |image| %> - <% credit = asset_credit(image) %> - <% next unless credit %>
"> - <%= credit %> + class="asset_credit_block<%= " headline_credit" if image == @headline_asset %>"> + <%= asset_credit(image) %>
<% end %>
diff --git a/app/views/content/_headline_image.html.erb b/app/views/content/_headline_image.html.erb index c764d22d..e7b821b9 100644 --- a/app/views/content/_headline_image.html.erb +++ b/app/views/content/_headline_image.html.erb @@ -5,8 +5,9 @@ image_tag(@headline_asset.upload.url(:headline)), @headline_asset.upload.url, :class => "glightbox", - :data => { :gallery => "page-#{@page.node.id}", :title => @headline_asset.name, - :description => "#credit_for_asset_#{@headline_asset.id}" } + :data => { :gallery => "page-#{@page.node.id}", + :glightbox => glightbox_data(@headline_asset, @headline_asset.name), + :"credit-selector" => (@headline_asset.has_credit? ? "#credit_for_asset_#{@headline_asset.id}" : nil) } ) %> <% if gallery_images.size > 1 %>
<%= "#{gallery_images.size} #{t(:images)}" %>
@@ -15,14 +16,16 @@ <%= link_to "#{gallery_images.size} #{t(:images)}, #{t(:open_gallery)}", gallery_images.first.upload.url, :class => "glightbox right", - :data => { :gallery => "page-#{@page.node.id}", :title => gallery_images.first.name, - :description => "#credit_for_asset_#{gallery_images.first.id}" } %> + :data => { :gallery => "page-#{@page.node.id}", + :glightbox => glightbox_data(gallery_images.first, gallery_images.first.name), + :"credit-selector" => (gallery_images.first.has_credit? ? "#credit_for_asset_#{gallery_images.first.id}" : nil) } %> <% end %> <% gallery_images.each do |image| %> <% next if image == @headline_asset %> <% next if !@headline_asset && image == gallery_images.first %> <%= link_to "", image.upload.url, :class => "glightbox", :style => "display: none", - :data => { :gallery => "page-#{@page.node.id}", :title => image.name, - :description => "#credit_for_asset_#{image.id}" } %> + :data => { :gallery => "page-#{@page.node.id}", + :glightbox => glightbox_data(image, image.name), + :"credit-selector" => (image.has_credit? ? "#credit_for_asset_#{image.id}" : nil) } %> <% end %> -- cgit v1.3