×

Notice

The forum is in read only mode.
Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1

TOPIC: Fix for Gravatar default image

Fix for Gravatar default image 10 years 8 months ago #21919

  • teckhardt
  • teckhardt's Avatar Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 2
  • Thank you received: 0
Version 5.0rc2, default image not used due to bug on gravity "request"
--- components/com_comment/helpers/avatars.php  2013-07-25 22:55:12.000000000 +0200
+++ components/com_comment/helpers/avatars.php-20130725 2013-07-25 22:54:29.000000000 +0200
@@ -52,7 +52,7 @@
                $size = 64;
                // Prepare the gravatar image
                $path = "https://secure.gravatar.com/avatar.php?gravatar_id=" . md5(strtolower($email)) .
-                       "&default=" . urlencode($default) . "&s=" . $size;
+                       "&default=" . urlencode($default) . "&s=" . $size;
 
                return $path;
        }

Fix for Gravatar default image 10 years 8 months ago #21953

  • teckhardt
  • teckhardt's Avatar Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 2
  • Thank you received: 0
another mini:
--- tmp/2/components/com_comment/templates/default/default_form.php     2013-06-11 15:07:44.000000000 +0200
+++ www/components/com_comment/templates/default/default_form.php       2013-07-26 20:52:09.000000000 +0200
@@ -153,7 +153,7 @@
                <div class="span4 muted small">
                <?php echo JText::_('COM_COMMENT_POSTING_AS'); ?>
                <?php if ($user->guest) : ?>
-                       <button class="btn-link btn-small ccomment-posting-as">{{user.getName}}</button>
+                       <button class="btn-link btn-small ccomment-posting-as"><?php echo JText::_('COM_COMMENT_ANONYMOUS'); ?></button>
                <?php else : ?>
                        <span class="ccomment-posting-as">
                        <?php if ($this->config->get('layout.use_name', 1)) : ?>

Fix for Gravatar default image 10 years 8 months ago #21954

  • Daniel Dimitrov
  • Daniel Dimitrov's Avatar
  • Away
  • Administrator
  • Administrator
  • Posts: 9618
  • Karma: 155
  • Thank you received: 1081
Hey teckhardt,
Thanks for the fixes, but to be honest I don't understand them.

replacing & with & is in my eyes incorrect. In the source code of a page you should use & mrcoles.com/blog/how-use-amersands-html-encode/

And the second fix - {{user.getName}} calls the javascript function getName on the user class. If the user is anonymous, he can still set a name. Setting all users to have the name of "anonymous" when they are not logged in is incorrect.

Can you explain why are you trying to fix those parts?

Regards,
Daniel

Fix for Gravatar default image 10 years 3 months ago #24200

  • Russell Walker
  • Russell Walker's Avatar
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 2
  • Thank you received: 0

Daniel Dimitrov wrote: Hey teckhardt,
replacing & with & is in my eyes incorrect. In the source code of a page you should use & mrcoles.com/blog/how-use-amersands-html-encode/


The problem is that the ampersand is being encoded twice. I can confirm that I also had the same problem as teckhardt - the default image was not being picked up because the ampersand was encoded twice in the URL (and thus the characters 'amp;' were being interpreted as part of the parameter name). When I changed line 87 of avatars.php to use an unencoded ampersand, the default image was shown correctly (I didn't investigate at what point the 2nd encoding took place). Note that even if the default image fails, gravatar still sends its own default image (which is an ugly 'G' logo), so you still get an image anyway - just not the one specified.

To reproduce the problem, just install CComment on a fresh Joomla 3.2 site, add some comments using an email address that doesn't have a gravatar, and you will see the image is a 'G', NOT the 'mystery man' image that comes with CComment. If you view the generated source (using the web developer toolbar or something similar), it shows the ampersand is encoded twice (firebug only shows it encoded once - I guess it does a decode first). Changing line 87 of avatars.php to use an unencoded ampersand will cause the correct 'mystery man' image to appear. That might not be the correct solution (it might be better to find out where the 2nd encoding is taking place), but it does work!

Fix for Gravatar default image 10 years 3 months ago #24204

  • Daniel Dimitrov
  • Daniel Dimitrov's Avatar
  • Away
  • Administrator
  • Administrator
  • Posts: 9618
  • Karma: 155
  • Thank you received: 1081
I see. The double encoding is most probably coming from the js replacement.
I changed the code - would you please test the dev. release and let me know if it works for you?
Since I work on localhost gravatar doesn't serve me any default image now...

Cheers,
Daniel
The following user(s) said Thank You: Russell Walker

Fix for Gravatar default image 10 years 3 months ago #24214

  • Russell Walker
  • Russell Walker's Avatar
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 2
  • Thank you received: 0
Thanks for the fast response - yes, the dev release is working fine.
  • Page:
  • 1
Time to create page: 0.120 seconds