WordPress.org

Ready to get started?Download WordPress

Forums

Display File Sizes
[resolved] How to Display File Size in single.php? (2 posts)

  1. Kelek
    Member
    Posted 5 months ago #

    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/

  2. Kelek
    Member
    Posted 5 months ago #

    Please ignore my message. I have found the answer from this source

    thanks

Reply

You must log in to post.

About this Plugin

About this Topic

Tags

No tags yet.