If you use social media for authenticating users on your site or you integrate with their profiles in your web application, you may want to display social media profile pictures in your site.
Most social media sites provide access to profile pictures via API. They may provide the pictures in multiple dimensions, but they don't necessarily match the requirements of your site design.
Cloudinary allows you to easily display social media profile pictures as part of your web application. You can display them in any dimension or aspect ratio you need. Cloudinary resizes or crops the pictures for you and delivers the images through a high performance CDN. Images can also be automatically refreshed when users change their profile pictures.
social delivery type: The social network delivery type. Supported values: facebook, twitter, gravatar.
social identifier: The unique identifier of the resource on the social network.
format file extension: (Optional) The requested delivery format of the image.
When a user accesses such a URL for the first time, Cloudinary downloads the appropriate profile picture from the social media site, stores it locally, and distributes it through a CDN. The next users to access it will receive the image quickly through the CDN.
Notes
Once you've fetched profile pictures from social media sites, you can find them in the Media Library by filtering the relevant image type from the More types field in the General tab of the advanced search.
Following Google's shutdown of its legacy Google+ API in March 2019, the Google+ (gplus) option is no longer available.
Following changes in Instagram in June 2020, the Instagram (instagram_name) option is no longer available.
To fetch profile pictures from Facebook, use the application-specific numeric Facebook ID as the social identifier and set the social delivery type to facebook.
Here's an example of fetching the Facebook profile picture for Bill Clinton:
To fetch profile pictures from Twitter, use either the Twitter User ID (delivery type = twitter) or Twitter Screen Name (delivery type = twitter_name) as the social identifier.
Here's an example of fetching the Twitter profile picture for Bill Clinton using the Twitter User ID:
// This SDK requires imports from @cloudinary/url-gen. Learn more in the SDK docs.new CloudinaryImage("BillClinton.jpg").setDeliveryType("twitter_name");
// This SDK requires imports from @cloudinary/url-gen. Learn more in the SDK docs.new CloudinaryImage("BillClinton.jpg").setDeliveryType("twitter_name");
// This SDK requires imports from @cloudinary/url-gen. Learn more in the SDK docs.new CloudinaryImage("BillClinton.jpg").setDeliveryType("twitter_name");
// This SDK requires imports from @cloudinary/url-gen. Learn more in the SDK docs.new CloudinaryImage("BillClinton.jpg").setDeliveryType("twitter_name");
To fetch profile pictures from Gravatar, use the user's email address which has been encoded with an MD5 hash as the social identifier and set the social delivery type to gravatar.
Here's an example of fetching the Gravatar picture for the email address info@cloudinary.com:
// This SDK requires imports from @cloudinary/url-gen. Learn more in the SDK docs.new CloudinaryImage("e3264cf16f34ecd3c7c564f5668cbc1e.jpg").setDeliveryType(
"gravatar"
);
// This SDK requires imports from @cloudinary/url-gen. Learn more in the SDK docs.new CloudinaryImage("e3264cf16f34ecd3c7c564f5668cbc1e.jpg").setDeliveryType(
"gravatar"
);
// This SDK requires imports from @cloudinary/url-gen. Learn more in the SDK docs.new CloudinaryImage("e3264cf16f34ecd3c7c564f5668cbc1e.jpg").setDeliveryType(
"gravatar"
);
// This SDK requires imports from @cloudinary/url-gen. Learn more in the SDK docs.new CloudinaryImage("e3264cf16f34ecd3c7c564f5668cbc1e.jpg").setDeliveryType(
"gravatar"
);
Cloudinary fetches a good quality resolution of the profile picture. To create transformed versions of users' profile pictures using your required image format and dimensions, pass transformation instructions as part of the URL, exactly as you would with your regular Cloudinary images.
For example, if the graphic design of your web site requires profile pictures in JPG of 80x120:
// This SDK requires imports from @cloudinary/url-gen. Learn more in the SDK docs.new CloudinaryImage("65646572251.jpg")
.resize(
fill()
.width(80)
.height(120)
.gravity(focusOn(face()))
)
.setDeliveryType("facebook");
// This SDK requires imports from @cloudinary/url-gen. Learn more in the SDK docs.new CloudinaryImage("65646572251.jpg")
.resize(
fill()
.width(80)
.height(120)
.gravity(focusOn(face()))
)
.setDeliveryType("facebook");
// This SDK requires imports from @cloudinary/url-gen. Learn more in the SDK docs.new CloudinaryImage("65646572251.jpg")
.resize(
fill()
.width(80)
.height(120)
.gravity(focusOn(face()))
)
.setDeliveryType("facebook");
// This SDK requires imports from @cloudinary/url-gen. Learn more in the SDK docs.new CloudinaryImage("65646572251.jpg")
.resize(
fill()
.width(80)
.height(120)
.gravity(focusOn(face()))
)
.setDeliveryType("facebook");
Note the use of the face-detection based gravity value in the above example (g_face in the URL) to ensure that the face remains in focus even when changing the image's aspect ratio.
See Image transformations for more details about the possible transformation options and the supported crop modes.
Cloudinary automatically checks whether profile pictures have changed, according to a pre-defined caching period. If a profile picture has changed, Cloudinary automatically re-fetches the original image as well as all transformed images. By default, profile images are checked for changes once every 7 days. Cloudinary customers with a paid account can request to change this default expiration time to any desired interval by submitting a support request.
You can also force an explicit refresh of a picture. When you use this option, the call returns the version of the new image, which you can use to bypass previously cached CDN copies. Alternatively, you can use the invalidate parameter, but if you do, make sure you are aware of the considerations involved in invalidating cached media assets on the CDN.
✔️ Feedback sent!
✖️
Error
Unfortunately there's been an error sending your feedback.