WordPress.org

Ready to get started?Download WordPress

Ideas

Why is Avatar stuff in pluggable.php?

  1. Pat Hawks
    Member

    12345

    Wouldn't it make life easier for everyone if get_avatar just called a couple filters or something?

    Additionally, why is there no real way to just get an avatar image URL? I don't always want a tag wrapped around it.

    Posted: 2 years ago #
  2. Ipstenu (Mika Epstein)
    Half-Elf Support Rogue & Mod

    get_avatar is hooked into gravatar, actually.

    http://en.gravatar.com/site/implement/images/php/

    Posted: 2 years ago #
  3. Pat Hawks
    Member

    12345

    Perhaps I didn't explain myself very well.

    I realize that, by default, get_avatar simply returns a Gravatar wrapped in an image tag.

    Some plugins, however, replace get_avatar with some function that pulls avatars from somewhere else (Facebook, Twitter, etc.). When this happens, there is no way for me to just get an avatar image url.
    I can call get_avatar and get the full image tag, but not just the URL. And because I can't even be sure what some random plugin will return for get_avatar, I don't really feel safe trying to regex a URL from the returned code.

    Why can't get_avatar work like most of the rest of WordPress.

    There should be two functions: get_avatar and get_avatar_url, or something to that effect.

    get_avatar_url Takes an email address, or userID, and generates a Gravatar URL, then runs it through a filter.
    If a plugin wants to change the image generated, they can just hook into that filter and return a different URL. Easy. No Mess.

    get_avatar would simply call get_avatar_url and wrap the URL in an image tag. Pass that through a filter, and there you have it.

    Does this make sense? I feel like I'm going crazy.

    Posted: 2 years ago #
  4. Jam Viet
    Member

    wordpress allow you to replace get_avatar by your own function so it's in pluggable.php is right ! i think it's unneccessary to change any thing here ...

    Posted: 2 years ago #
  5. Ipstenu (Mika Epstein)
    Half-Elf Support Rogue & Mod

    By design, WP is coded to work avatars with gravatar, so there's no need for the other stuff. And since Gravatar provides a way to pull in the image URL, putting a function in for that would be easily done, but not necessary except to make double the function, for something you have to reproduce anyway.

    Certainly could though, sure.

    Some plugins, however, replace get_avatar with some function that pulls avatars from somewhere else (Facebook, Twitter, etc.). When this happens, there is no way for me to just get an avatar image url.

    I'd argue those plugins should be doing the work, though really what's the point of getting just the image and not wrapping in an image tag? What are you going to do with the image, if not display it?

    Posted: 2 years ago #
  6. Pat Hawks
    Member

    12345

    What I specifically want to do (this time) is use an avatar as a thumbnail on user profile pages.
    I need a way to get just a users avatar URL to wrap it in <meta> tags (for Open Graph, etc.)

    <meta name="thumbnail" content="http://example/foo.jpg" />
    <meta property="http://ogp.me/ns#image" content="http://example/foo.jpg"/>

    If a plugin has replaced get_avatar() I'm out of luck.
    If show_avatars is turned off, I'm out of luck.

    In another instance from a few months ago, I wanted to use CSS to display avatar images as a background rather than wrapped in an <img> tag, but I was out of luck.

    Posted: 2 years ago #
  7. Pat Hawks
    Member

    12345

    Another case I ran into today:
    There is no reliable way to add a class or id to an avatar returned with get_avatar()
    This wouldn't be a problem if I could use a filterable function like get_avatar_url()

    Posted: 2 years ago #
  8. Pat Hawks
    Member

    12345

    It seems like it's a textbook case of mixing content and presentation.

    If I'm writing a plugin that changes where the avatars come from, why do I care how they are styled.

    If I want to change how they are styled, why should I assume they're all coming from Gravatar?

    Why should the whole function be in pluggable.php when a filter is just as good?

    (I'm going to keep coming back to this until things change, or I understand why they won't change)

    Posted: 2 years ago #
  9. Ipstenu (Mika Epstein)
    Half-Elf Support Rogue & Mod

    You made a trac ticket. I would really suggest you not spam the ideas forums with it more, it's kind of nagging.

    I (personally) see your point, though the only use-case that makes sense is using it in a background (and for that, I'd just grab Gravatar's function in and of itself). I'm not 100% sure how much get_avatar is tied into the comment system, and how much a hassle it'd be to unravel it.

    But you made your point :) Don't belabor ;)

    Posted: 2 years ago #
  10. Pat Hawks
    Member

    12345

    mea culpa.

    Posted: 2 years ago #

RSS feed for this topic

Reply

You must log in to post.

  • Rating

    12345
    6 Votes
  • Status

    This idea is under consideration