Facebook Twitter Instagram
    TecAdmin
    • Home
    • Ubuntu 20.04
      • Upgrade Ubuntu
      • Install Java
      • Install Node.js
      • Install Docker
      • Install LAMP Stack
    • Tutorials
      • AWS
      • Shell Scripting
      • Docker
      • Git
      • MongoDB
    • FeedBack
    • Submit Article
    • About Us
    Facebook Twitter Instagram
    TecAdmin
    Home»Programming»PHP»HOw to Get Gravatar Image with PHP

    HOw to Get Gravatar Image with PHP

    RahulBy RahulApril 7, 20151 Min ReadUpdated:June 3, 2019

    When you are creating an application and want to display the user’s image on their profile picture. This can be a better option for you to take users image from there Gravatar account, from where we can simply get the image using their email address.

    PHP
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    <?php
     
    $email_id = "[email protected]";
    $default = "";
    $size = 200;
     
    $gravatar_url = "http://www.gravatar.com/avatar/" . md5(strtolower(trim($email))) . "?d=" . urlencode($default) . "&s=" . $size;
     
    header("content-type: image/jpeg");
    echo file_get_contents($gravatar_url);
    ?>

    Copy the above PHP script and use in your php code to show users gravatar in their profiles.

    Gravtar PHP
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email WhatsApp
    Previous ArticleHow to Check File Permissions in Bash Script
    Next Article How To Install PHP 5.6 & 7.3 on Ubuntu 18.04

    Related Posts

    How To Install PHP (8.1, 7.4 or 5.6) on Ubuntu 22.04

    Updated:May 9, 20223 Mins Read

    How To Install Linux, Nginx, MySQL, & PHP (LEMP Stack) on Ubuntu 22.04

    Updated:April 7, 20227 Mins Read

    How To Install LAMP Stack on Ubuntu 22.04 LTS

    Updated:April 20, 20225 Mins Read

    How To Setup Apache, PHP & MongoDB in Ubuntu & Debian

    Updated:October 8, 20213 Mins Read

    How To Install and Use PHP Composer on Debian 11

    Updated:February 16, 20224 Mins Read

    How To Install PHP (8.1, 7.4 & 5.6) on Debian 11

    Updated:February 16, 20224 Mins Read

    Leave A Reply Cancel Reply

    Recent Posts
    • How to Install JAVA on Ubuntu 22.04
    • Switching Display Manager in Ubuntu – GDM, LightDM & SDDM
    • Changing the Login Screen Background in Ubuntu 22.04 & 20.04
    • How To Install PHP (8.1, 7.4 or 5.6) on Ubuntu 22.04
    • (Resolved) Please install all available updates for your release before upgrading
    Facebook Twitter Instagram Pinterest
    © 2022 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.