diff --git a/app/controllers/media_controller.rb b/app/controllers/media_controller.rb index 5f7a933961389a4fc8c752f49391ca08b3887978..ed2a6238668fbfcc16695caea0ba5fdf843386f5 100644 --- a/app/controllers/media_controller.rb +++ b/app/controllers/media_controller.rb @@ -5,7 +5,13 @@ class MediaController < ApplicationController if @blob.variable? variant_service = VariantService.compute(@blob, params[:filename_with_transformations], params[:format]) transformations = variant_service.transformations - blob_or_variant_url = transformations.empty? ? url_for(@blob) : url_for(@blob.variant(transformations)) + if transformations.empty? + blob_or_variant_url = url_for @blob + else + variant = @blob.variant transformations + @size = variant.processed.image.byte_size + blob_or_variant_url = url_for variant + end else blob_or_variant_url = url_for(@blob) end diff --git a/app/models/communication/website/menu/item.rb b/app/models/communication/website/menu/item.rb index 9ab4d9cc9f4b514294cb3ebe1276cc5b11f7c746..9fbd01862815b3eef3ab7b0ce35c201e011edab2 100644 --- a/app/models/communication/website/menu/item.rb +++ b/app/models/communication/website/menu/item.rb @@ -80,7 +80,6 @@ class Communication::Website::Menu::Item < ApplicationRecord target = nil active = website.send "menu_item_kind_#{kind}?" return nil unless active - published = about&.published && about&.published_at case self.kind when 'blank' target = '' @@ -95,7 +94,7 @@ class Communication::Website::Menu::Item < ApplicationRecord when 'news' target = "/#{website.static_pathname_posts}" when 'news_article' - target = "/#{website.static_pathname_posts}#{about.path}" if published + target = "/#{website.static_pathname_posts}#{about.path}" if about&.published && about&.published_at when 'staff' target = "/#{website.static_pathname_staff}" when 'administrators' @@ -109,11 +108,11 @@ class Communication::Website::Menu::Item < ApplicationRecord when 'research_volumes' target = "/#{website.static_pathname_research_volumes}" when 'research_volume' - target = "/#{website.static_pathname_research_volumes}#{about.path}" if published + target = "/#{website.static_pathname_research_volumes}#{about.path}" if about&.published && about&.published_at when 'research_articles' target = "/#{website.static_pathname_research_articles}" when 'research_article' - target = "/#{website.static_pathname_research_articles}#{about.path}" if published + target = "/#{website.static_pathname_research_articles}#{about.path}" if about&.published && about&.published_at else target = about&.path end