Fix cover photo resize and filenaming conventions

This commit is contained in:
Champ Camba
2019-01-21 19:39:38 +08:00
parent 52be3719d5
commit 59ab53d84f
2 changed files with 17 additions and 9 deletions
+9 -1
View File
@@ -1006,8 +1006,16 @@ if ( ! class_exists( 'um\core\Uploader' ) ) {
$sizes_array[ ] = array ('width' => $size );
}
$image->multi_resize( $sizes_array );
$resize = $image->multi_resize( $sizes_array );
// change filenames of resized images
foreach( $resize as $row ){
$new_filename = str_replace( "x{$row['height']}" , "", $row["file"] );
$old_filename = $row["file"];
rename( dirname( $image_path ) . DIRECTORY_SEPARATOR . $old_filename, dirname( $image_path ) . DIRECTORY_SEPARATOR . $new_filename );
}
} else {
wp_send_json_error( esc_js( __( "Unable to crop image file: {$src}", 'ultimate-member' ) ) );
}