Display image size (pixels and bytes) in admin edit images area

Hi,

my first post, tried to search but did not find anything, so here we go.

Is there an easy way to add the size of the images (pixels and bytes) in the admin area where you edit the image title, description, etc?

I might be able to dig into the PHP code and attempt to add this myself, however, if someone already know how to do it, any help will be greatly appreciates.

Thanks for a great program,

-avi

Comments

  • Answering my own question:

    Here is how I added the image size and file size to the admin area:

    1) in admin.php after line 719 (or whereever you want to display the info) add the following:

    `

    Image size:
    <?= $image->getWidth() ?>W x <?= $image->getHeight() ?>H


    File size:
    <?= byteConvert(filesize($image->getLocalPath())) ?>

    `
    2) at bottom of functions.php (before the final ?> add the following:

    `
    /** avc
    * Parses a byte size from a size value (eg: 100M).
    */
    function byteConvert( $bytes ) {

    if ($bytes<=0)
    return '0 Byte';

    $convention=1024; //[1000->10^x|1024->2^x]
    $s=array('Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB');
    $e=floor(log($bytes,$convention));
    return round($bytes/pow($convention,$e),2).' '.$s[$e];
    }
    `
    3) in class-image.php after getFileName() line 134 add:

    `
    /** avc
    * Returns The full SERVER path to the original image
    *
    * @return string
    */
    function getLocalPath() {
    return $this->localpath;
    }
    `
    Hope this helps.

    -avi
  • acrylian Administrator, Developer
    It is actually not recommended to hack any core files since you will loose this with every update. But this is probably not a bad idea to have on the admin pages. You could create a ticket for that and attach the code there then we might add that in one of the future versions.
Sign In or Register to comment.