• Resolved cannon303

    (@cannon303)


    Hi is there a way I can add in my functions.php a snippet to allow different image sizes for the image uploader field in Ultimate Member plugin please? I can see in the plugin backend you can register different sizes for the profile picture but don’t know how to do it for the image uploader field. The usual function for general WordPress image upload like this:

    add_image_size( ‘custom-size’, 130, 85, false );

    doesn’t seem to work with this plugin as far as I can tell.

    Thanks.

    • This topic was modified 3 years, 7 months ago by cannon303.
Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Contributor Champ Camba

    (@champsupertramp)

    Hi @cannon303

    Unfortunately, there’s no filter hook to add custom sizes. You will have to use an action hook and retrieve the saved filename and then resize it with custom resize PHP.

    You can use this action hook um_after_upload_db_meta:

    add_action("um_after_upload_db_meta", "um_040921_resize_image", 10, 2 );
    function um_040921_resize_image( $user_id, $field_key ){
      $user_dir = UM()->uploader()->get_upload_user_base_dir( $user_id );
      $filename = get_user_meta( $user_id, $field_key, true );
      $file = $user_dir. DIRECTORY_SEPARATOR . $filename;
    
      // do resize with $file
    }

    The above action hook is triggered when a user has uploaded the image.

    Regards,

    Thread Starter cannon303

    (@cannon303)

    ok thanks very much for the info. I just need to work out how to create some custom resize script and then I’m there.

    Plugin Contributor Champ Camba

    (@champsupertramp)

    Hey there!

    This thread has been inactive for a while so we’re going to go ahead and mark it Resolved.

    Please feel free to re-open this thread by changing the Topic Status to ‘Not Resolved’ if any other questions come up and we’d be happy to help. ??

    Regards,

    I think a different action hook is needed here, @champsupertramp. When the um_after_upload_db_meta action fires, the new image has not yet been uploaded to the file location indicated. This only occurs once the profile is updated (saved).

    I’m pretty sure the um_upload_image_result filter is a better place to achieve what is required.

    Great plugin.

    • This reply was modified 3 years, 3 months ago by 1968phillip.
    • This reply was modified 3 years, 3 months ago by 1968phillip.
    • This reply was modified 3 years, 3 months ago by 1968phillip.
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Ultimate member image sizes’ is closed to new replies.