説明
指定したファイル (例えば PDF、JPG、PNG) のファイルサイズを取得するための簡単なショートコードです。
人間が読み取り可能な形式で、バイトが収まる最大の単位を使用します。
使用法
投稿の本文に次のようにショートコードを設置してください。
[filesize]http://yoursite.com/path/to/file.pdf[/filesize]
もしくは url 属性を代わりに使用することもできます。
[filesize url='http://yoursite.com/path/to/file.pdf']
テーマファイルにこのように設置することもできます。
<?php echo do_shortcode('[filesize]http://yoursite.com/path/to/file.pdf[/filesize]'); ?>
ノート
- ファイルは自サーバーに存在しなければなりません。
- PHP の filesize 関数の仕様上、2MB を超えるファイルについて、異なる数値が表示されることがあります。
インストール
get-filesize-shortcode
フォルダーを/wp-content/plugins/
ディレクトリへアップロードしてください- WordPress の「プラグイン」メニューから有効化してください。
FAQ
まだありません。
評価
2019年1月8日
Thanks for this plugin. It saves my time
2018年1月15日
I'm using Toolset Types plugin for collecting attachments to the post. The plugin gives the URL path of my attachment. I needed to display the size of my attachment in my template. This plugin did the job. Other places I looked, we needed the ID of the attachment from the DB and it was a complicated and probably SQL-heavy way to query the wp database to find the ID from the URL. This plugin accomplishes the task without needing to check the database (I checked the plugin code.. no db lookup)
貢献者と開発者
変更履歴
1.0.10
- 2019年8月7日
- readme.txt を更新
1.0.8
- 2018年8月16日
- readme.txt を更新、寄付リンクを削除
1.0.4
- 2018年8月16日
- readme.txt を更新
1.0.3
- マイナーバグフィックス
1.0.2
- 2018年8月16日
- url 属性をサポート