On the WordPress Edit Image Screen, I’d like to add a label to show the current compression level and byte file size of the image.
Any ideas how to tap into this screen and echo this data?
The current settings show:
- Date
- URL
- File name
- File type
- Dimensions
I’d like to ad
- File Size
- File Compression (echo the current jpeg_quality setting)
2 Answers
You can try to use the attachment_submitbox_misc_actions
filter to add more info to the box. Here is an example for the filesize part:
add_action( 'attachment_submitbox_misc_actions', 'custom_fileinfo_wpse_98608' );
function custom_fileinfo_wpse_98608(){
global $post;
$meta = wp_get_attachment_metadata( $post->ID );
$upload_dir = wp_upload_dir();
$filepath = $upload_dir['basedir']."https://wordpress.stackexchange.com/".$meta['file'];
$filesize = filesize($filepath);
?>
<div class="misc-pub-section">
<?php _e( 'File Size:' ); ?> <strong><?php echo $filesize; ?> </strong> <?php _e( 'bytes' ); ?>
</div>
<?php
}
The default file info is displayed with the attachment_submitbox_metadata()
function through this action:
add_action( 'attachment_submitbox_misc_actions', 'attachment_submitbox_metadata' );
in the file /wp-admin/includes/media.php