commit 7afa99dab59f08b97560053f408c61c6fee90412
parent e8f08967c2aba6014dd56c12c9cfe3f2a4bec464
Author: MTRNord <mtrnord1@gmail.com>
Date: Thu, 16 Apr 2015 17:33:01 +0200
add gravatar phote API
Diffstat:
1 file changed, 26 insertions(+), 0 deletions(-)
diff --git a/core/libs/gravatar.php b/core/libs/gravatar.php
@@ -0,0 +1,26 @@
+<?php
+/**
+ * Get either a Gravatar URL or complete image tag for a specified email address.
+ *
+ * @param string $email The email address
+ * @param string $s Size in pixels, defaults to 80px [ 1 - 2048 ]
+ * @param string $d Default imageset to use [ 404 | mm | identicon | monsterid | wavatar ]
+ * @param string $r Maximum rating (inclusive) [ g | pg | r | x ]
+ * @param boole $img True to return a complete IMG tag False for just the URL
+ * @param array $atts Optional, additional key/value attributes to include in the IMG tag
+ * @return String containing either just a URL or a complete image tag
+ * @source http://gravatar.com/site/implement/images/php/
+ */
+function get_gravatar( $email, $s = 80, $d = 'mm', $r = 'g', $img = false, $atts = array() ) {
+ $url = 'http://www.gravatar.com/avatar/';
+ $url .= md5( strtolower( trim( $email ) ) );
+ $url .= "?s=$s&d=$d&r=$r";
+ if ( $img ) {
+ $url = '<img src="' . $url . '"';
+ foreach ( $atts as $key => $val )
+ $url .= ' ' . $key . '="' . $val . '"';
+ $url .= ' />';
+ }
+ return $url;
+}
+?>