[WordPress] 外掛分享: Get Filesize Shortcode

首頁外掛目錄 › Get Filesize Shortcode
WordPress 外掛 Get Filesize Shortcode 的封面圖片
200+
安裝啟用
★★★★★
5/5 分(3 則評價)
247 天前
最後更新
問題解決
WordPress 5.8+ PHP 5.6+ v1.3.0 上架:2015-01-20

內容簡介

「Get Filesize Shortcode」是一個簡單的短碼外掛,可以以可讀的格式以最大可讀單位顯示文件(例如 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]'); ?> 放到你的樣本中。

注意事項

檔案必須存放在你的伺服器上
對於超過 2MB 的文件,可能會因 PHP 的檔案大小規範而返回不同的數字。

外掛標籤

開發者團隊

⬇ 下載最新版 (v1.3.0) 或搜尋安裝

① 下載 ZIP → 後台「外掛 › 安裝外掛 › 上傳外掛」
② 後台搜尋「Get Filesize Shortcode」→ 直接安裝(推薦)
📦 歷史版本下載

原文外掛簡介

“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.
Usage
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 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.
Note

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.

延伸相關外掛

文章
Filter
Apply Filters
Mastodon