Merge pull request #1339 from ZogStriP/fix-custom-avatars-in-email

FIX: custom avatars in email
This commit is contained in:
Robin Ward 2013-08-16 07:18:34 -07:00
commit 30caa0d0b0
2 changed files with 5 additions and 3 deletions

View file

@ -308,7 +308,7 @@ class User < ActiveRecord::Base
# - emails
def small_avatar_url
template = avatar_template
template.gsub("{size}", "60")
template.gsub("{size}", "45")
end
def avatar_template

View file

@ -21,8 +21,10 @@ module Jobs
# create a temp file with the same extension as the original
temp_file = Tempfile.new(["discourse-avatar", File.extname(original_path)])
temp_path = temp_file.path
#
Discourse.store.store_avatar(temp_file, upload, size) if ImageSorcery.new(original_path).convert(temp_path, gravity: "center", thumbnail: "#{size}x#{size}^", extent: "#{size}x#{size}", background: "transparent")
# create a centered square thumbnail
if ImageSorcery.new(original_path).convert(temp_path, gravity: "center", thumbnail: "#{size}x#{size}^", extent: "#{size}x#{size}", background: "transparent")
Discourse.store.store_avatar(temp_file, upload, size)
end
# close && remove temp file
temp_file.close!
end