Actions
Patch #37599
closedRemove extra call of Attachment#thumbnailable? in AttachmentsController#thumbnail
Description
In AttachmentsController#thumbnail, you can find the following code. It checks the return value of @attachment.thumbnailable?
.
def thumbnail
if @attachment.thumbnailable? && tbnail = @attachment.thumbnail(:size => params[:size])
However, it is unnecessary because Attachment#thumbnailable?
is also called in Attachmnet#thumbnail as follows.
def thumbnail(options={})
if thumbnailable? && readable?
Therefore, we can safely remove the call of Attachment#thumbnailable?
. See the patch below.
diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb
index aa8bbeec9..612e070d2 100644
--- a/app/controllers/attachments_controller.rb
+++ b/app/controllers/attachments_controller.rb
@@ -83,7 +83,7 @@ class AttachmentsController < ApplicationController
end
def thumbnail
- if @attachment.thumbnailable? && tbnail = @attachment.thumbnail(:size => params[:size])
+ if (tbnail = @attachment.thumbnail(:size => params[:size]))
if stale?(:etag => tbnail, :template => false)
send_file(
tbnail,
Actions