mirror of
https://github.com/simi/omniauth-facebook.git
synced 2022-11-09 12:32:45 -05:00
add option to specify image size
This commit is contained in:
parent
9a7cde8c7b
commit
bd4aa5c315
3 changed files with 9 additions and 1 deletions
|
@ -37,6 +37,7 @@ You can configure several options, which you pass in to the `provider` method vi
|
|||
* `scope`: A comma-separated list of permissions you want to request from the user. See the Facebook docs for a full list of available permissions: http://developers.facebook.com/docs/reference/api/permissions. Default: `email`
|
||||
* `display`: The display context to show the authentication page. Options are: `page`, `popup`, `iframe`, `touch` and `wap`. Read the Facebook docs for more details: http://developers.facebook.com/docs/reference/dialogs#display. Default: `page`
|
||||
* `secure_image_url`: Set to `true` to use https for the avatar image url returned in the authentication hash. Default is `false`.
|
||||
* `image_size`: Set the size for the returned image url in the auth hash. Valid options are `square` (50x50), `small` (50 pixels wide, variable height), `normal` (100 pixels wide, variable height), or `large` (about 200 pixels wide, variable height). Default is `square` (50x50).
|
||||
|
||||
For example, to request `email`, `user_birthday` and `read_stream` permissions and display the authentication page in a popup window:
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ module OmniAuth
|
|||
'name' => raw_info['name'],
|
||||
'first_name' => raw_info['first_name'],
|
||||
'last_name' => raw_info['last_name'],
|
||||
'image' => "#{options[:secure_image_url] ? 'https' : 'http'}://graph.facebook.com/#{uid}/picture?type=square",
|
||||
'image' => "#{options[:secure_image_url] ? 'https' : 'http'}://graph.facebook.com/#{uid}/picture?type=#{options[:image_size] || 'square'}",
|
||||
'description' => raw_info['bio'],
|
||||
'urls' => {
|
||||
'Facebook' => raw_info['link'],
|
||||
|
|
|
@ -233,6 +233,13 @@ describe OmniAuth::Strategies::Facebook do
|
|||
subject.stub(:raw_info) { raw_info }
|
||||
subject.info['image'].should eq('https://graph.facebook.com/321/picture?type=square')
|
||||
end
|
||||
|
||||
it 'returns the image size specified in the `image_size` option' do
|
||||
@options = { :image_size => 'normal' }
|
||||
raw_info = { 'name' => 'Fred Smith', 'id' => '321' }
|
||||
subject.stub(:raw_info) { raw_info }
|
||||
subject.info['image'].should eq('http://graph.facebook.com/321/picture?type=normal')
|
||||
end
|
||||
end
|
||||
|
||||
describe '#raw_info' do
|
||||
|
|
Loading…
Reference in a new issue