diff --git a/app/controllers/media_controller.rb b/app/controllers/media_controller.rb index e8710637f395cebacc132ef059d739d048ed4201..1a0aefdc4bffa04f4151e707369a4c0bf95407ee 100644 --- a/app/controllers/media_controller.rb +++ b/app/controllers/media_controller.rb @@ -6,6 +6,6 @@ class MediaController < ApplicationController blob_or_variant_url = transformations.empty? ? url_for(@blob) : url_for(@blob.variant(transformations)) - render json: { transformations: transformations, url: blob_or_variant_url } + redirect_to blob_or_variant_url end end diff --git a/app/views/active_storage/blobs/jekyll.html.erb b/app/views/active_storage/blobs/jekyll.html.erb index 5591fe2bdb55d3f24a7e51bd0a5b93be2ceb5176..34b0c7c1f82b479e9317b85e8049d4052df795c1 100644 --- a/app/views/active_storage/blobs/jekyll.html.erb +++ b/app/views/active_storage/blobs/jekyll.html.erb @@ -1,6 +1,9 @@ <% width, height = @blob.metadata.values_at('width', 'height') ratio = width.present? && height.present? ? (width.to_f / height.to_f) : nil +university = University.find_by(id: @blob.university_id) +base_url = university&.url || "" +media_endpoint_path = medium_path(signed_id: @blob.signed_id, filename_with_transformations: @blob.filename) %> <%# TODO: Replace @blob.url with the media endpoint when it's ready %> <%= raw({ @@ -9,5 +12,5 @@ ratio = width.present? && height.present? ? (width.to_f / height.to_f) : nil "width" => width, "height" => height, "ratio" => ratio, - "url" => @blob.url + "url" => "#{base_url}#{media_endpoint_path}" }.compact.to_yaml) %> diff --git a/test/models/variant_service_test.rb b/test/models/variant_service_test.rb index dcbe6cd51a28a59f979e830ee36524ed163d9343..62858b2e977509748c7a11cadba1f54d14ec9cf0 100644 --- a/test/models/variant_service_test.rb +++ b/test/models/variant_service_test.rb @@ -6,12 +6,10 @@ class VariantServiceTest < ActiveSupport::TestCase include ActiveRecord::TestFixtures setup do - ActiveStorage::Current.host = "https://example.com" @was_tracking, ActiveStorage.track_variants = ActiveStorage.track_variants, false end teardown do - ActiveStorage::Current.reset ActiveStorage.track_variants = @was_tracking end