Skip to content

Commit

Permalink
= 4.2.6.4 =
Browse files Browse the repository at this point in the history
~ Tweak: get_file_size_from_url method.
  • Loading branch information
tungnxt89 committed Mar 5, 2024
1 parent de968fc commit ab10824
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions inc/class-lp-file-system.php
Original file line number Diff line number Diff line change
Expand Up @@ -329,18 +329,31 @@ public function move( $source_path, $des_path, bool $overwrite = true ): bool {

return $output;
}

public function download_url( $url, $timeout = 300, $signature_verification = false ) {
return download_url( $url, $timeout, $signature_verification );
}

public function lp_handle_upload( &$file, $overrides = false, $time = null ) {
return wp_handle_upload( $file, $overrides, $time );
}

/**
* Get size of file from url
*
* @param $url
*
* @return string
* @since 4.2.3
* @version 1.0.1
*/
public function get_file_size_from_url( $url ) {
$tmp_file = $this->download_url( $url );
$size = '0KB';
if ( $tmp_file ) {
$size = '';
if ( $tmp_file && ! is_wp_error( $tmp_file ) ) {
$size = ( filesize( $tmp_file ) / 1024 < 1024 ) ? round( filesize( $tmp_file ) / 1024, 2 ) . 'KB' : round( filesize( $tmp_file ) / 1024 / 1024, 2 ) . 'MB';
}

return $size;
}
}
Expand Down

0 comments on commit ab10824

Please sign in to comment.