I need to display some featured image info on post page. Among other info I need to display file size of image (featured image of post).
I tried this function inside single.php.
<?php
function getSize($file){
$bytes = filesize($file);
$s = array('b', 'Kb', 'Mb', 'Gb');
$e = floor(log($bytes)/log(1024));
return sprintf('%.2f '.$s[$e], ($bytes/pow(1024, floor($e))));
}
?>
and to echo that:
<?php echo getSize('/wp-content/uploads/2014/06/some-file-name.jpg'); ?>
It works, but I need help to make ti automatically grab featured image url, not to manually enter it in code?
For example I use this to echo featured image ("full") url:
<?php
if ( has_post_thumbnail()) {
$full_image_url = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'full');
echo $thumb_image_url[0];
}
?>
Could you please help to combine it, or to provide me with another solution?