Forums

get_avatar with a link? (3 posts)

  1. dbvista
    Member
    Posted 2 years ago #

    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?

  2. dbvista
    Member
    Posted 2 years ago #

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

  3. dbvista
    Member
    Posted 2 years ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.