Conversation
This was tested using https://wordpress.org/plugins/wp-user-avatar/, which has 200,000 active installs. This will handle local avatars that are using get_avatar() for functionality. Solves Automattic#14, for most cases. There are likely edge cases where this may not work, but for the most part, I imagine this will add support for local avatars.
|
|
Thanks for the info. I will check that out and revise accordingly |
|
I checked out As far as DOM parsing vs. regex it is probably a sound idea to use regex, since it is only an image tag being parsed but I always personally feel safer using DOM as it is less error prone. If you could expand a bit on your thoughts about using |
|
/**
* Filter the avatar URL.
*
* @since 4.2.0
*
* @param string $url The URL of the avatar.
* @param mixed $id_or_email The Gravatar to retrieve. Accepts a user_id, gravatar md5 hash,
* user email, WP_User object, WP_Post object, or WP_Comment object.
* @param array $args Arguments passed to get_avatar_data(), after processing.
*/
$args['url'] = apply_filters( 'get_avatar_url', $url, $id_or_email, $args );
/**
* Filter the avatar data.
*
* @since 4.2.0
*
* @param array $args Arguments passed to get_avatar_data(), after processing.
* @param mixed $id_or_email The Gravatar to retrieve. Accepts a user_id, gravatar md5 hash,
* user email, WP_User object, WP_Post object, or WP_Comment object.
*/
return apply_filters( 'get_avatar_data', $args, $id_or_email );Any plugin that adds an option for local avatars should be using one or both of these filters to make WordPress aware of them. And then any plugin that uses |
|
Right, I agree that is the better implementation and how a plugin should interact with avatars. However, this https://wordpress.org/plugins/wp-user-avatar/, which has 200,000 active installs, uses the hook Would it be acceptable to use |
|
Honestly, I have zero interest in adding workarounds to o2 to support outdated plugins that choose not to use filters that have been available and known for about a year now (since 4.2), regardless of the size of their user base. If a plugin is doing it wrong, we shouldn't also do it wrong just to follow suit. |
Merging master to keep up to date.
…avatar-support # Conflicts: # js/collections/users.js
Changed to use only get_avatar_url(). This is the proper function to use and agreement was reached for not adding backwards compatibility for get_avatar hook.
|
Let me know if there are other changes to be made. Thank you for the feedback! |
This was tested using https://wordpress.org/plugins/wp-user-avatar/,
which has 200,000 active installs. This will handle local avatars that
are using get_avatar() for functionality. Solves #14, for most cases.
There are likely edge cases where this may not work, but for the most
part, I imagine this will add support for local avatars.