Skip to content

Instantly share code, notes, and snippets.


Chris G. swchris

View GitHub Profile
swchris / get_social_avatar.php
Last active Sep 27, 2016 — forked from jcsrb/gist:1081548
PHP function (conversion of @jcsrb Javascript function at to output URL for social icons from google, facebook, gravatar, twitter, tumblr and instagram)
View get_social_avatar.php
function get_avatar_from_service($service, $userid, $size) {
// Based on original Javascript function at
// 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 use get_avatar_from_service('twitter', username, default )
// for tumblr use get_avatar_from_service('tumblr', blog-url, size-in-px )