• dbvista

    (@dbvista)


    I wrote a plugin that uses the get_avatar filter to display custom images, and it’s breaking with the Admin Bar in 3.1. Any advice appreciated.

    The IMG tags returned by my plugin are wrapped in an A tag to make the image into a link. This hash always worked fine for avatars in comments, etc. Unfortunately the Admin Bar in 3.1 wraps the result of get_avatar() in an “A” tag, assuming it’s just an IMG, which causes a nested “A” tag situation like this:

    <a href="admin bar-supplied URL"><a href="my custom URL"><img .../></a></a>

    which breaks the HTML of the page.

    If I modify my plugin to remove my “A” tag, this fixes the Admin Bar, but my avatars are no longer linked to my custom URL.

    What is the right way, in 3.1, to make avatars clickable and linked to a custom URL?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter dbvista

    (@dbvista)

    Or alternatively, can my plugin detect when it’s in the Admin Bar and strip off the “A” tag only in that situation?

    Thread Starter dbvista

    (@dbvista)

    My current hack is to check the $size argument of the get_avatar callback. If it’s equal to 16, it’s the Admin Bar, because our avatars are all larger than 16 pixels wide. It’s a lousy hack but is working so far.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘get_avatar with a link?’ is closed to new replies.