• Resolved tea23hah

    (@tea23hah)


    Hi,

    is there an option to upload an avatar picture from the media library?

    And why does it size down the images that much? When I upload a 500×500 image the plugin sizes it down to 150×150 which is way to small for the author archive.

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author pepe

    (@pputzer)

    Right now, you can only upload images, not select from the Media Library. However, that’s a feature on my to-do list.

    Regarding image sizing, the original uploaded image is not resized. However, served copies are cached in the requested size (so that depends on your theme). Please note that unless you deliberately change the markup via filters, avatars generated by WordPress include a double-density srcset for hires devices. So if your theme requests an image with 100 pixels, there will be a second image for the srcset attribute with 200 pixels per side.

    Thread Starter tea23hah

    (@tea23hah)

    Thanks for your quick reply.

    So I used this simple author box plugin before and it always served the image in the exact resolution I uploaded on the author page, so it’s not theme related is it? I am using generatepress.

    Is there a way to disable the checkbox in the comment form?

    I am really just looking for a lightweight plugin to upload local avatars and yours seems to be the best and actually only option without loads unnecessary features…

    Regarding the media library, any idea when you’ll have the time to implement this?

    Plugin Author pepe

    (@pputzer)

    Well, whether it’s a plugin or the theme, they all use the WordPress function get_avatar() which has a $size parameter as its second argument. “Avatar providers” won’t necessarily serve an image exactly in the requested size, but Avatar Privacy does because it already has the infrastructure for scaling and caching images in place. Serving an image larger than requested would be wasteful of bandwidth. If you want a larger image in a particular template, make sure that the second parameter is set to an appropriate number of pixels and all will be fine.

    Regarding your second question, yes, the checkbox can be disabled using this code snippet (no “anonymous” commenter will be recorded as consenting to Gravatar use though):

    \add_filter( 'comment_form_fields', function( $fields ) { unset( $fields['use_gravatar'] ); return $fields; }, 20 );

    As to Media Library support, I can’t promise much more than “probably in 2020” (depends on my spare time and what else is going on).

    Thread Starter tea23hah

    (@tea23hah)

    Do you happen to have a snippet to always serve the original image?

    Regarding the media library, even a adding an image from an URL would be helpful already. Where are the images stored that are uploaded with your plugin? Isn’t adding an additional upload option an unnecessary?

    Thanks for your help!

    Plugin Author pepe

    (@pputzer)

    The uploaded files are stored in UPLOADS/avatar-privacy/user-avatar. The plugin uses separate uploads instead of integrating with the Media Library because that was easier to implement at the time.

    Serving the original image for uploaded files is doable, but please take the following snippet with a grain of salt – I’m doing this off the cuff, the code has not been run and does not include any error checking:

    
    \add_filter( 'avatar_privacy_user_avatar_icon_url', function( $url, $hash, $size, $args ) {
       return \get_site_url() . '/' . \str_replace( ABSPATH, '', $args['avatar'] );
    }, 20, 4 );
    
    Thread Starter tea23hah

    (@tea23hah)

    Great, thank you very much!

    Is the uploader of the plugin making sure users can only upload pictures?

    Would you recommend disabling any .php in the upload folder of your plugin for security reasons?

    Plugin Author pepe

    (@pputzer)

    Hi @tea23hah, Avatar Privacy uses the standard wp_handle_upload() and further restricts the allowed MIME types to image/jpeg, image/gif, and image/png.

    Avatar Privacy does not put any PHP files into its subfolder of the uploads directory, so yes, you can disable PHP execution.

    Thread Starter tea23hah

    (@tea23hah)

    Awesome, appreciate your quick replies and thanks for making this plugin!

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Upload from Media Libraty’ is closed to new replies.