Support » Plugin: Display File Sizes » How to Display File Size in single.php?

  • Resolved Hardinal

    (@hardinal)


    Hi, I am sorry for my English. I am very noob in PHP. I wonder how to put it on my article (single.php). For example I have an article that display an image. I want to display the size of this image.

    I have put this code to my function.php (CMIIW):

    function get_file_size( $file_url = '' ) {
    		if ( empty( $file_url ) )
    			return;
    
    		$sizes = apply_filters( 'dfs_size_types', array( 'Bytes', 'KB', 'MB', 'GB' ) );
    		$file_size = filesize( esc_url( $file_url ) );
    
    		$i = floor( log( $file_size, 1024 ) );
    
    		if ( $i > 1 )
    			return round( $file_size / pow( 1024, $i ), 1 ) . ' ' . $sizes[ $i ];
    		else
    			return round( $file_size / pow( 1024, $i ) ) . ' ' . $sizes[ $i ];
    	}

    Now I wonder which part of your plugin I should on my single.php.

    Is that possible?

    Thanks

    http://wordpress.org/plugins/display-file-sizes/

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘How to Display File Size in single.php?’ is closed to new replies.