Configuring avatar image sizes using Omniauth Facebook

818 views Asked by At

Right now I'm trying to save large images for a user's avatar using Omniauth Facebook and Paperclip. It appears that after the user is created only the smallest image size is saved. I did some research and came across an answer that said to pass :image_size as a parameter. Unfortunately it doesn't exactly say where it goes. I assumed that it went in my devise.rb file but did not work:

Devise.setup do |config|
  ...
  config.omniauth :facebook, "APP_ID", "SECRET_KEY", secure_image_url: true, image_size: "large"
end

Where exactly am I putting this to get it to work?

1

There are 1 answers

0
Anya M. On

If you're using Omniauth Gem, you should be able to set a custom image size by passing it as a parameter and providing width and height in omniauth.rb file like so:

Rails.application.config.middleware.use OmniAuth::Builder do
provider :facebook, "APP_ID", "SECRET_KEY",
{
scope: 'email,public_profile,user_location,user_birthday,user_about_me',
image_size: {width: 400, height: 400},
info_fields: 'name,email'
}
end