Support Users Directly Uploading Profile Pictures.

* Adds a `picture` attribute to `User`.
* Preserves Gravatar as a fallback option.
* Now, you should use `user.profile_picturer` instead of `gravatar_url`
* TODO: Ensure `profile_picture` handles sizing right for uploaded images.
This commit is contained in:
Michael Ball 2020-07-14 21:06:15 -07:00
parent b66f69599a
commit 3883188dcd
13 changed files with 43 additions and 18 deletions

View file

@ -10,8 +10,16 @@
= f.input :nickname, as: :string, hint: 'This is how the other users see you, not your real name'
.control-label
= "Avatar"
= image_tag(@user.gravatar_url(size: '48'), title: "Yo #{@user.name}!", alt: '')
= image_tag(@user.profile_picture(size: '48'), title: "Yo #{@user.name}!", alt: '')
= link_to 'Change your avatar here', 'https://gravatar.com'
%br
%p
Or upload a picture.
= image_tag f.object.picture.thumb.url if f.object.picture?
- if @user.picture?
= image_tag(@user.picture.thumb.url, width: '20%')
= f.input :picture, hint: 'If you upload a picture, it will be used in place of Gravatar.'
= f.input :affiliation, as: :string,
hint: 'This could be a company, a user group, or nothing at all.'
= f.input :biography, input_html: { rows: 5, data: { provide: 'markdown' } },

View file

@ -3,7 +3,7 @@
.col-md-12
.page-header
%h1
= image_tag(@user.gravatar_url(size: '48'), title: "Yo #{@user.name}!", alt: '')
= image_tag(@user.profile_picture(size: '48'), title: "Yo #{@user.name}!", alt: '')
= @user.name
%small
= @user.nickname