We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 33033
    • 43 Posts
    Quote from: rthrash at Nov 06, 2006, 09:48 AM

    I’d assume similar support for Gravatars could be done this way ... and if so anyone care to take a stab at it?
    I took a quick look at gravatars (never heard of it before) and this should work. You can’t sign up for a gravatar right now so I can’t really see if it works, but the default image shows up for me, so it should be good.

    Make a snippet named phx:gravatar and save following code.
    <?php
    /*Once the gravatar URL is created, you can output it whenever you please:
    
    <img src="[+comment.createdby:userinfo=`email`:gravatar+]" alt="gravatar" />
    */
    $email = "[email protected]";
    $default = "http://www.yoursite.com/assets/images/logo.png";
    $size = 80;
    $rating = R;
    
    $newvalue= "http://www.gravatar.com/avatar.php?
    gravatar_id=".md5($output).
    "&default=".urlencode($default).
    "&size=".$size.
    "&rating=".$rating;
    return $newvalue;
    ?>
    

    In your Jot template add
    <img src="[+comment.createdby:userinfo=`email`:gravatar+]" alt="gravatar" />
    where you want the gravatar to be.

    Can someone who has a gravatar try this to be sure it works?
      • 8028
      • 4 Posts
      <?php
      /*Once the gravatar URL is created, you can output it whenever you please:
      E-mail value extract from additional input "email" form on page 
      Example (Jot call): [+phx:gravatar=`[+comment.custom.email+]`+]
      */
      
      $default_email = "[email protected]";
      $size = 80;
      $rating = R;
      $email = '';
      
      (empty($options))?$email=$default_email:$email=$options;
      
      $newvalue= "http://www.gravatar.com/avatar.php?
      gravatar_id=".md5($email).
      "&size=".$size.
      "&rating=".$rating;
      return $newvalue;
      ?>


      rolleyes
        • 7403
        • 1 Posts
        After a lot of staring at it, seems this is the best way to handle the gravatar code in your template: chunk.comment.inc.html
        This fixes problems with either the Guest EMail works or the Registered User EMail works but not both by checking to see if the comment was left by a Registered User and providing the correct gravatar ’call’ based on that (works great on my site).
        Place this code where you want the gravatar to appear (Jot Call)...
        [+comment.createdby:isnt=`0`:then=`<img src="[+comment.createdby:userinfo=`email`:gravatar+]" alt="gravatar" />`:else=`<br /><img src="[+comment.custom.email:gravatar+]" alt="gravatar" />`+]
        
        

        Use the phx:gravatar snippet from these posts as shown here...
        $size = 80;
        $rating = R;
        $email = '[email protected]';
        
        $newvalue= "http://www.gravatar.com/avatar.php?
        gravatar_id=".md5(strtolower($output)).
        "&default=".urlencode($default).
        "&size=".$size.
        "&rating=".$rating;
        return $newvalue;
        

        Notice I left the $default variable out, at least on my setup I get a ’red-x’ when I try to pass a default image, not sure why because if I copy the image properties (URL) to a new window it does show the default image I am passing. In any case, by removing it you simply get the default gravatar ’G’ for users without a gravatar, which is better than the ’red-x’.

        If anyone has/had the same problem passing the default image and figured out how to fix it PLEASE let me know how...

        You can see the gravatar code working here:
        South Florida StormWatch
          • 20413
          • 2,877 Posts
          Example (Jot call): [+phx:gravatar=`[+comment.custom.email+]`+]

          Should be <img src="[+phx:gravatar=`[+comment.custom.email+]`+]" alt="" />

          Then its just adding the custom email input to form and call it with &customfields=`email`

          SWEET! cool

          //This requires PHx plugin to be installed!
            @hawproductions | http://mrhaw.com/

            Infograph: MODX Advanced Install in 7 steps:
            http://forums.modx.com/thread/96954/infograph-modx-advanced-install-in-7-steps

            Recap: Portland, OR (PDX) MODX CMS Meetup, Oct 6, 2015. US Bancorp Tower
            http://mrhaw.com/modx_portland_oregon_pdx_modx_cms_meetup_oct_2015_us_bancorp_tower