Merge pull request 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
app/models
lib/jobs

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

@ -21,8 +21,10 @@ module Jobs
# create a temp file with the same extension as the original # create a temp file with the same extension as the original
temp_file = Tempfile.new(["discourse-avatar", File.extname(original_path)]) temp_file = Tempfile.new(["discourse-avatar", File.extname(original_path)])
temp_path = temp_file.path temp_path = temp_file.path
# # create a centered square thumbnail
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") 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 # close && remove temp file
temp_file.close! temp_file.close!
end end