0

When I call the following code:

echo get_avatar(
    get_the_author_meta('user_email'), 
    '70', 
    get_bloginfo('template_directory')."/images/default.png"
);

It generates the following:

[http://1.gravatar.com/avatar/f456a030d4086504d0796f0134139410?s=70&d=http%3A%2F%2Fblogs.com%2Fscience-and-medical%2Fwp-content%2Fthemes%2FBlog%2Fimages%2Fdefault.png%3Fs%3D70&r=G][1]

It is adding to the end of the default URL:

%3Fs%3D70

This prevents it from working and always returns the default image. If you remove the extra data from the URL it works.

  • Quotes were needed around the parameter – John Aug 1 '12 at 8:01
  • Please add this as answer, then mark it as solution in 2 days. Thanks. – kaiser Aug 1 '12 at 11:23
  • Will do, just at the moment the system will not let me – John Aug 1 '12 at 11:34
  • Sure, you can add an answer. What exactly does the system tell you? – kaiser Aug 1 '12 at 12:35
  • "Users with less than 10 reputation can't answer their own question for 8 hours after asking. You may self-answer in 2 hours. Until then please use comments, or edit your question instead." - So guess just need to wait – John Aug 1 '12 at 13:10
1

I worked out I needed to add quotes around the parameter.

echo get_avatar(get_the_author_meta('user_email'), '70', "'" . get_bloginfo('template_directory')."/images/default.png'");

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.