pdf: lib: add the method to return attachment from filename and encoding (#3261)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@7912 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
@@ -517,6 +517,19 @@ module Redmine
|
||||
end
|
||||
txt
|
||||
end
|
||||
|
||||
def self.attach(attachments, filename, encoding)
|
||||
filename_utf8 = Redmine::CodesetUtil.to_utf8(filename, encoding)
|
||||
atta = nil
|
||||
if filename_utf8 =~ /^[^\/"]+\.(gif|jpg|jpe|jpeg|png)$/i
|
||||
atta = Attachment.latest_attach(attachments, filename_utf8)
|
||||
end
|
||||
if atta && atta.readable? && atta.visible?
|
||||
return atta
|
||||
else
|
||||
return nil
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user