Git Product home page Git Product logo

wp-user-avatars's Introduction

WP User Avatars

Synopsis

A WordPress plugin to allow registered users to upload & select their own avatars.

Motivation

I decided to create this plugin because no existing solutions integrated into WordPress in a way that felt native to me. I also wanted something that more tightly integrated with my WP User Profiles plugin.

Installation

  • Download and install using the built in WordPress plugin installer.
  • Activate in the "Plugins" area of your admin by clicking the "Activate" link.
  • Consider sponsoring future development by clicking "Sponsor".
  • No further setup or configuration is necessary.

Help

Contributors

  • Created by @JJJ
  • Made better by @nash-ye
  • Pull requests welcome!

Contributing

Please open a new issue to discuss whether the feature is a good fit for the project. Once you've decided to work on a pull request, please follow the WordPress Coding Standards.

wp-user-avatars's People

Contributors

jjj avatar johnbillion avatar misfist avatar nash-ye avatar ocean90 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

wp-user-avatars's Issues

Avoid switch_to_blog unless necessary

Currently if on multisite a switch_to_blog is performed every single time an avatar URL is is asked for a user that has an avatar.

If wp_user_avatars_dynamic_resize is filtered to return false and there's no media ID then it will just switch back and forth. This should be avoided.

Unnecessary database queries on credits page

WP User Avatars filters get_avatar_url to see if the email belongs to a WordPress user and if that user has a custom avatar.

On wp-admin/credits.php, this results in about 100 unnecessary database queries like this:

SELECT *
FROM wp_users
WHERE user_email = '[email protected]'

To prevent this, I suggest skipping avatar retrieval for @md5.gravatar.com email addresses.

Right now I'd need to manually unhook wp_user_avatars_filter_get_avatar_url() for such cases, but a fix in the plugin makes more sense to me.

bbPress profile page integration

I was hoping this might work for a bbPress user profile page, from this type of url:
/forums/user/username/edit/

Indeed the form shows up nicely, however upload fails with the "ERROR: Are you sure you wanted to do that?" message, and also silently fails to remove existing picture if one has been assigned at the back end.
(tested on wp4.7.5 running twenty-sixteen with all plugins deactivated apart from bbpress and wp-user-avatars)

Noting #6 mentions an upcoming wp-user-dashboard is this now available?

RTL Support

We need RTL (Right To Left) styling support.

Ask: Image not show when set avatar

Hi,

Apologies for this, currently i had 3 sites when use wp-user-avatars the image which set for the avatar not working image wont set instead white page background only (show like attached file). Does any permission file / something i need to check to fix the issue (i do believe the issue come from the site though not the plugins as it work on other sites)
image

I had tested change the permission folder into something not too strict but seem it wont have an affect. Perhaps for wp-user-avatars will it be create some files / directories or link to some directory instead ?

Appreciate any advice for this. Again my apologies & many thanks

Bring the avatar ratings onto one line

I'm a stickler for detail. The radio button for the X rating wraps onto the next line. It would be great if it didn't.

Tested using:

  • Chrome 89
  • macOS 10.15
  • WordPress 5.6

Selector for moving submit button is too generic

$( '#your-profile p.submit' ).appendTo( $( '#wp-user-avatars-user-settings' ) );

If there's any other p.submit element in the document it gets also moved into the meta box. This currently happens with the Two Factor plugin activated:

image
https://github.com/WordPress/two-factor/blob/529c973deb4677e45cc243b1336dd718aa472611/providers/class.two-factor-fido-u2f-admin-list-table.php#L136

A fix would be to only move the last element to the box.

Front-end support

It would be really cool.

WP User Avatar plugin has this feature, but the code is not good, and not extensible, and it's not on github. I would prefer using your plugin, John, but it's critical for me to have a front-end area to upload (and ideally crop).
Something similar to BuddyPress but with no direct BuddyPress connection, so it can be used separately.

Confusing difference in behaviour between "Choose file" and "Choose from Media"

When using the "Choose from Media" button, the preview is updated instantly and the change is saved to the user's account without having to press the "Update" button.

When using the "Choose file" button (the input type="file" input) and selecting a file, nothing happens. You first need to click the "Update" button to both see the preview and to save the change. This isn't intuitive and I actually thought a JavaScript error on the page had broken something.

It would be great if, upon selecting an image, the preview changed and the new image was saved to the user's account automatically, so its behaviour matched that of using the media library.

Gravatar requests are not blocked in comments list table

When Gravatar requests are blocked the default mystery image in the comments list table is still requested from gravatar.com.

It looks like this is caused by get_avatar( $comment, 32, 'mystery' ); in WP_Comments_List_Table::floated_admin_avatar(). Removing the mystery default loads the local image.

current_user_can( 'edit_avatar', $user->ID ) check isn't working for non-admins

The avatar section isn't showing up for non-admins (tested in WP v4.3.1/2) because the test for current_user_can( 'edit_avatar', $user->ID ) is mapping to the list_users cap instead of the edit_user cap.

Turns out you can't just map to a cap like "edit_user" and expect that check to work out. I think (unless I missed something) you need checks like this to return no cap when checking edit_avatar for a specific user ID.

case 'edit_avatar' :
            if(user_can($user_id, "edit_user", $args[0])) {
                $caps = array();
                break;
            }

I also think it makes sense to use "edit_users" instead of "list_users" for the other (non-singular) caps.

I have a patch I can open a pull request with if you are okay with this.

WebP Support

Hi there!

Thanks for the great plugin!

Since 5.8, WP has WebP support, but WP User Avatarss uploader doesn’t seem to support it. When attempting to upload a WebP image from the User Profile edit page, there is an error: “Avatar upload failed”. Adding a WebP image from the Media Library does work, however.

I assume this because WebP isn’t set as one of the accepted image formats:

// Handle upload
$avatar = wp_handle_upload( $_FILES['wp-user-avatars'], array(
    'mimes' => array(
        'jpg|jpeg|jpe' => 'image/jpeg',
        'gif'          => 'image/gif',
        'png'          => 'image/png',
    ),
    'test_form' => false,
    'unique_filename_callback' => 'wp_user_avatars_unique_filename_callback'
) );

https://github.com/stuttter/wp-user-avatars/blob/master/wp-user-avatars/includes/common.php#L56-L64

Would it be possible to allow WebP images in the upload?

ref: https://make.wordpress.org/core/2021/06/07/wordpress-5-8-adds-webp-support/

Note: This is duplicated on the WP support forum here: https://wordpress.org/support/topic/webp-support-35/

Unable to keep custom class set to image when activated

Previously, I was able to set a class and other parameters tot he image tag when using default Wordpress avatars using this:

get_avatar($user->ID, 150, null, get_the_author(array('class'=>'img-responsive img-circle center-block'))

But now, when this plugin is activated, it doesn't take this standard function, and my classes disappear. How can I get the above call to work with your plugin and apply the class, and size?

Doesn't work when profile is on frontend, e.g. with Theme My Login's themed profiles.

I've added this code to the core plugin file, which solves an issue with admin functions not being available, but it seems there is more needed to get the actual uploads working which I couldn't figure out quickly.

BTW, I mentioned that TML didn't set IS_PROFILE_PAGE, but it does... just later than the check you already have in place.

/**
 * Later check for some admin files that might be loaded from the front end.
 * e.g. for Theme My Login themed profiles module support.
*/
function wp_user_avatars_load_admin_files()
{
    if(is_admin() || (defined('IS_PROFILE_PAGE') && IS_PROFILE_PAGE))
    {
        $plugin_path = plugin_dir_path( __FILE__ );
        require_once $plugin_path . 'includes/admin.php';
        require_once $plugin_path . 'includes/ajax.php';
    }
}
add_action('template_redirect', 'wp_user_avatars_load_admin_files', 11);

I'm guessing that the AJAX/JS needs to be tweaked to properly run on the frontend.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.