"Get Filesize Shortcode" is a simple shortcode to get filesize of a file( eg. PDF, JPG, PNG ... ) with a human readable format, using the largest unit the bytes will fit into.
Now added Get filesize block to display file link with file size.
用法
Put
[filesize]http://yoursite.com/path/to/file.pdf[/filesize]
anywhere in a post.
Or you can use url attr instead.
[filesize url='http://yoursite.com/path/to/file.pdf']
Also you can place
<?php echo do_shortcode('[filesize]http://yoursite.com/path/to/file.pdf[/filesize]'); ?>
in your templates.
As to "Get filesize" block, search 'get filesize' in Text block category and insert it.
Set file title and file url, and it generates a text link to the file with file size afterwards.
You can toggle Preview/Edit by clicking Preview/Edit button in toolbar of the block.
笔记
- File must be in your server
- With files larger than 2MB, it might return different number due to the spec of filesize function of PHP.