get user profile large picture from facebook with omniauth in devise 2.0

hyperrjas picture hyperrjas · May 10, 2012 · Viewed 12.8k times · Source

I want get the user profile large or normal picture from facebook. Now I get the square version from user profile picture with this code:

:image => access_token.info.image
# http://graph.facebook.com/id/picture?type=square

How can I get the large or normal versions?

Or and the app, How can I replace in this url the last word, large instead square...

Thank you very much!

Answer

Derek Lucas picture Derek Lucas · Jun 7, 2012

If you want to grab a different size picture at login time, the omniauth-facebook strategy has an option to change which picture is requested.

image_size: Set the size for the returned image url in the auth hash.

For example, the large picture would be requested in omniauth.rb this way:

provider :facebook, 'secrets', 'sekrets', :image_size => 'large'

https://github.com/mkdynamic/omniauth-facebook#configuring