Follow along with the video below to see how to install our site as a web app on your home screen.
Примечание: This feature may not be available in some browsers.
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))));
}
<?php
$attachments = get_posts( array(
'post_type' => 'attachment',
'posts_per_page' => -1,
'post_parent' => $post->ID,
'exclude' => get_post_thumbnail_id()
) )
if ( $attachments ) {
echo '<ul>';
foreach ( $attachments as $attachment ) {
$url = wp_get_attachment_url( $attachment->ID );
$title = get_the_title( $attachment->ID );
$filesize = getSize( get_attached_file( $attachment->ID ) );
echo '<li><a href="'.$url.'">' . $title . '</a> (' . $filesize . ')</li>';
}
echo '</ul>';
}
?>
if (!is_file($file)) return 0;