WPUserManager / wp-user-manager

Beautifully simple user profile directories with frontend login, registration and account customization. WP User Manager is the best solution to manage your community and your users for WordPress.
https://wpusermanager.com/
GNU General Public License v3.0
36 stars 20 forks source link

Replace the avatar upload field with filepond #10

Open alessandrotesoro opened 6 years ago

kushsharma commented 5 years ago

Hey, can we prioritize this? Currently, Remove button of avatar in account settings is also not working. But the biggest issue is we are not resizing the image for avatar after upload. That means if a user uploads an image 4K resolution, we keep it like that only. And in the profile page of the user, that whole 4k image is going to download then render downscaled via CSS.

Filepond can fix both of the issues at once.

For the time being I have modified the functions.php of plugin file to achieve this.

      if ( ! in_array( $file['type'], $allowed_mime_types ) ) {
        if ( $args['file_label'] ) {
            return new WP_Error( 'upload', sprintf( __( '"%1$s" (filetype %2$s) needs to be one of the following file types: %3$s', 'wp-user-manager' ), $args['file_label'], $file['type'], implode( ', ', array_keys( $allowed_mime_types ) ) ) );
        } else {
            return new WP_Error( 'upload', sprintf( __( 'Uploaded files need to be one of the following file types: %s', 'wp-user-manager' ), implode( ', ', array_keys( $allowed_mime_types ) ) ) );
        }
    } else {
        $upload = wp_handle_upload( $file, apply_filters( 'submit_wpum_wp_handle_upload_overrides', array( 'test_form' => false ) ) );
        if ( ! empty( $upload['error'] ) ) {
            return new WP_Error( 'upload', $upload['error'] );
        } else {
            $file_url =$upload['url'];
            $file_path = $upload['file'];

            if($wpum_uploading_file === 'user_avatar') {
                //if its user_avatar, resize it to some sensible dimensions
                $default_name = basename( $upload['file'] );
                $meta_data = image_make_intermediate_size( $upload['file'], 100, 100, false );

                $file_url = str_replace($default_name, $meta_data['file'], $upload['url']);
                $file_path = str_replace($default_name, $meta_data['file'], $upload['file']);
            }           

            $uploaded_file->url       = $file_url;
            $uploaded_file->file      = $file_path;
            $uploaded_file->name      = basename( $file_path );
            $uploaded_file->type      = $upload['type'];
            $uploaded_file->size      = $file['size'];
            $uploaded_file->extension = substr( strrchr( $uploaded_file->name, '.' ), 1 );
        }
    }
polevaultweb commented 3 years ago

https://github.com/pqina/filepond/issues/91#issuecomment-457516545

polevaultweb commented 3 years ago

@kushsharma are you still using the plugin? Do you have the issue with removing the avatar still?

polevaultweb commented 3 years ago

Vote https://wordpress.org/support/topic/adding-filepond-as-uploader-2/