Skip to content

Instantly share code, notes, and snippets.

View swchris's full-sized avatar

Chris G. swchris

View GitHub Profile
@swchris
swchris / get_social_avatar.php
Last active September 27, 2016 12:15 — forked from jcsrb/gist:1081548
PHP function (conversion of @jcsrb Javascript function at https://gist.github.com/jcsrb/1081548) to output URL for social icons from google, facebook, gravatar, twitter, tumblr and instagram)
<?
function get_avatar_from_service($service, $userid, $size) {
// Based on original Javascript function at https://gist.github.com/jcsrb/1081548
// this return the url that redirects to the according user image/avatar/profile picture
// implemented services: google profiles, facebook, gravatar, twitter, tumblr, default fallback
// for google use get_avatar_from_service('google', profile-name or user-id , size-in-px )
// for facebook use get_avatar_from_service('facebook', vanity url or user-id , size-in-px or size-as-word )
// for gravatar use get_avatar_from_service('gravatar', md5 hash email@adress, size-in-px )
// for twitter (via avatars.io) use get_avatar_from_service('twitter', username, default )
// for tumblr use get_avatar_from_service('tumblr', blog-url, size-in-px )