diff --git a/app/controllers/content_controller.rb b/app/controllers/content_controller.rb index d912fda6..3b1a28cc 100644 --- a/app/controllers/content_controller.rb +++ b/app/controllers/content_controller.rb @@ -123,6 +123,14 @@ class ContentController < ApplicationController return if ENV.key?('CONTENT_BLACKLIST') && ENV['CONTENT_BLACKLIST'].split(',').include?(@content.user.try(:email)) @serialized_content = ContentSerializer.new(@content) + + @primary_image = @content.primary_image + @other_images = @content.image_uploads.where.not(id: @primary_image.try(:id)) + @basil_images = @content.basil_commissions.where.not(saved_at: nil) + end + + def references + end def new diff --git a/app/models/concerns/has_image_uploads.rb b/app/models/concerns/has_image_uploads.rb index 684bb79a..adccccfd 100644 --- a/app/models/concerns/has_image_uploads.rb +++ b/app/models/concerns/has_image_uploads.rb @@ -8,6 +8,11 @@ module HasImageUploads # todo: dependent: :destroy_async # todo: destroy from s3 on destroy + def primary_image + # self.image_uploads.find_by(primary: true) || self.image_uploads.first + self.image_uploads.first + end + def public_image_uploads self.image_uploads.where(privacy: 'public').presence || [header_asset_for(self.class.name)] end diff --git a/app/views/content/gallery.html.erb b/app/views/content/gallery.html.erb index 1e2a5162..5c24121a 100644 --- a/app/views/content/gallery.html.erb +++ b/app/views/content/gallery.html.erb @@ -36,29 +36,32 @@ - -
+ <%= link_to @primary_image.src.url do %>
+ <%= image_tag @primary_image.src.url, class: 'block object-cover object-center w-full h-full rounded hover:opacity-90', alt: "Primary image for #{@content.name}" %>
+ <% end %>
+ <% @other_images.each do |image| %>
+
+ <% end %>
+ <% @basil_images.each do |commission| %>
+
-
-
-
-