Upload preview: use normalized image url
This means that the preview will work even when the user doesn't use the direct image link. e.g. The user can use the bookmarklet on Pixiv mode=medium pages.
This commit is contained in:
@@ -8,6 +8,15 @@ class UploadsController < ApplicationController
|
||||
@upload = Upload.new(:rating => "q")
|
||||
if params[:url]
|
||||
@post = Post.find_by_source(params[:url])
|
||||
|
||||
@normalized_url = params[:url]
|
||||
headers = {
|
||||
"User-Agent" => "#{Danbooru.config.safe_app_name}/#{Danbooru.config.version}"
|
||||
}
|
||||
Downloads::Strategies::Base.strategies.each do |strategy|
|
||||
@normalized_url, headers = strategy.new.rewrite(@normalized_url, headers)
|
||||
end
|
||||
|
||||
begin
|
||||
@source = Sources::Site.new(params[:url])
|
||||
rescue Exception
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<% if params[:url] %>
|
||||
<%= image_tag(params[:url], :title => "Preview", :id => "image") %>
|
||||
<%= image_tag(@normalized_url, :title => "Preview", :id => "image") %>
|
||||
<% if params[:ref] %>
|
||||
<p><strong>Referrer: </strong> <%= params[:ref] %></p>
|
||||
<% end %>
|
||||
|
||||
Reference in New Issue
Block a user