Created
November 26, 2019 14:31
-
-
Save champsupertramp/171ec60db9d82474d7e62b390da965bf to your computer and use it in GitHub Desktop.
Ultimate Member 2.0 - Profile Photo custom Width and Height
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter("um_upload_image_process__profile_photo","um_custom_profile_photo_size", 1, 7 ); | |
function um_custom_profile_photo_size( $response, $image_path, $src, $key, $user_id, $coord, $crop ){ | |
$quality = UM()->options()->get( 'image_compression' ); | |
$image = wp_get_image_editor( $image_path ); // Return an implementation that extends WP_Image_Editor | |
$temp_image_path = $image_path; | |
//refresh image_path to make temporary image permanently after upload, generates file name e.g. profile_photo-custom.jpeg | |
$image_path = pathinfo( $image_path, PATHINFO_DIRNAME ) . DIRECTORY_SEPARATOR . $key . '-custom.' . pathinfo( $image_path, PATHINFO_EXTENSION ); | |
if ( ! is_wp_error( $image ) ) { | |
// Resizes image to 200 width x 600 height | |
$image->resize( 200, 600, true ); | |
$image->set_quality( $quality ); | |
// Saves image | |
$image->save( $image_path ); | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment