Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save champsupertramp/171ec60db9d82474d7e62b390da965bf to your computer and use it in GitHub Desktop.
Save champsupertramp/171ec60db9d82474d7e62b390da965bf to your computer and use it in GitHub Desktop.
Ultimate Member 2.0 - Profile Photo custom Width and Height
<?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