From 8f3f58e3010fa7c923b77b7d2050175890b58f9b Mon Sep 17 00:00:00 2001 From: erdgeist Date: Tue, 21 Jul 2026 23:17:56 +0200 Subject: Render PDF headlines as document cards, not lightbox images A starred PDF previously ran through the same crop-and-lightbox path a photo does -- exactly the awkward treatment explicit headline designation was meant to avoid. _headline_image.html.erb now branches on @headline_asset.pdf?: a PDF renders as a linked card (a :medium thumbnail, a file icon, its name), no gallery participation at all. The existing image-headline and gallery-fallback logic is otherwise unchanged, now scoped to an image-specific headline only. Other attached PDFs -- headlined or not -- list below as plain links, same reasoning as why non-headline photos still get a gallery trigger: an attached document shouldn't go invisible just because nothing's been starred yet. headline_image's own render guard needed widening to cover a page with PDFs attached but no images and no headline at all -- the one case none of the existing conditions accounted for. --- app/views/content/_headline_image.html.erb | 42 +++++++++++++++++++++++++----- 1 file changed, 35 insertions(+), 7 deletions(-) (limited to 'app/views') diff --git a/app/views/content/_headline_image.html.erb b/app/views/content/_headline_image.html.erb index 13a4ac78..4a3dfdc0 100644 --- a/app/views/content/_headline_image.html.erb +++ b/app/views/content/_headline_image.html.erb @@ -1,13 +1,25 @@ <% gallery_images = @page.assets.images %> +<% image_headline = @headline_asset if @headline_asset&.image? %> +<% other_pdfs = @page.assets.pdfs.where.not(id: @headline_asset&.id) %> -<% if @headline_asset %> +<% if @headline_asset&.pdf? %> + <%= link_to @headline_asset.upload.url, :class => "headline_document_card", :target => "_blank", :rel => "noopener" do %> + <%= image_tag @headline_asset.upload.url(:medium), :alt => "", :class => "headline_document_card_thumb" %> +
+ <%= icon("file-text", library: "tabler", "aria-hidden": true) %> + <%= @headline_asset.name %> +
+ <% end %> +<% end %> + +<% if image_headline %> <%= link_to( - image_tag(@headline_asset.upload.url(:headline)), - @headline_asset.upload.url, + image_tag(image_headline.upload.url(:headline)), + image_headline.upload.url, :class => "glightbox", :data => { :gallery => "page-#{@page.node.id}", - :glightbox => glightbox_data(@headline_asset, @headline_asset.name), - :"credit-selector" => (@headline_asset.show_credit? ? "#credit_for_asset_#{@headline_asset.id}" : nil) } + :glightbox => glightbox_data(image_headline, image_headline.name), + :"credit-selector" => (image_headline.show_credit? ? "#credit_for_asset_#{image_headline.id}" : nil) } ) %> <% if gallery_images.size > 1 %>
<%= "#{gallery_images.size} #{t(:images)}" %>
@@ -22,10 +34,26 @@ <% end %> <% gallery_images.each do |image| %> - <% next if image == @headline_asset %> - <% next if !@headline_asset && image == gallery_images.first %> + <% next if image == image_headline %> + <% next if !image_headline && image == gallery_images.first %> <%= link_to "", image.upload.url, :class => "glightbox", :style => "display: none", :data => { :gallery => "page-#{@page.node.id}", :glightbox => glightbox_data(image, image.name), :"credit-selector" => (image.show_credit? ? "#credit_for_asset_#{image.id}" : nil) } %> <% end %> + +<% if other_pdfs.any? %> + +<% end %> -- cgit v1.3