Support selecting various sizes of profile pics

This commit is contained in:
Michael Ball 2020-07-15 23:27:22 -07:00
parent 3883188dcd
commit 10d58ef050
5 changed files with 26 additions and 8 deletions

View file

@ -158,9 +158,17 @@ class User < ApplicationRecord
##
# Returns a user's profile picture URL.
# Partials should *not* directly call `gravatar_url`
def profile_picture(opts)
# TODO: Figure out how to align sizes?
picture.thumb.url || gravatar_url(opts)
def profile_picture(opts = {})
return gravatar_url(opts) unless picture.present?
puts "ASKED FOR PROFILE PIC!! #{opts[:size]}"
size = (opts[:size] || 0).to_i
if size < 50
picture.tiny.url
elsif size <= 100
picture.thumb.url
else
picture.large.url
end
end
def self.for_ichain_username(username, attributes)