diff --git a/app/controllers/media_controller.rb b/app/controllers/media_controller.rb index ce015dd1b..ba95213a2 100644 --- a/app/controllers/media_controller.rb +++ b/app/controllers/media_controller.rb @@ -27,7 +27,14 @@ class MediaController < ApplicationController private def set_media_attachment - @media_attachment = MediaAttachment.attached.find_by!(shortcode: params[:id] || params[:medium_id]) + id = params[:id] || params[:medium_id] + if id.nil? + return + elsif id.size == 19 # SecureRandom.url_safe(14) + @media_attachment = MediaAttachment.local.attached.find_by!(shortcode: id) + else + @media_attachment = MediaAttachment.local.attached.find_by!(id: id) + end end def verify_permitted_status! diff --git a/app/models/media_attachment.rb b/app/models/media_attachment.rb index 66d800b7b..949abc384 100644 --- a/app/models/media_attachment.rb +++ b/app/models/media_attachment.rb @@ -218,7 +218,7 @@ class MediaAttachment < ApplicationRecord end def to_param - shortcode + shortcode.presence || id&.to_s end def focus=(point)