[WordPress] 外掛分享: Upload Media Exif Date

首頁外掛目錄 › Upload Media Exif Date
200+
安裝啟用
★★★★★
5/5 分(2 則評價)
111 天前
最後更新
問題解決
WordPress 4.7+ PHP 8.0+ v1.08 上架:2020-05-25

內容簡介

將圖像註冊到媒體庫

將 EXIF 資訊的日期/時間更改為檔名的日期/時間。

相關外掛

Exif Caption
Exif Details

如何使用過濾器鉤子的範例

範例程式碼

/** ==================================================
* Upload Media Exif Date 的範例程式碼
*
* 透過原始的過濾器鉤子('umed_postdate'),
* 當無法從 EXIF 中讀取日期與時間時,從檔名中獲取日期和時間。
*
* @param string $postdate postdate。
* @param string $filename 檔名。
*/
function umed_postdate_from_filename( $postdate, $filename ) {

/* 範例檔名:20191120_183022.jpg */
$year = substr( $filename, 0, 4 );
$month = substr( $filename, 4, 2 );
$day = substr( $filename, 6, 2 );
$hour = substr( $filename, 9, 2 );
$minute = substr( $filename, 11, 2 );
$second = substr( $filename, 13, 2 );

$postdate = $year . '-' . $month . '-' . $day . ' ' . $hour . ':' . $minute . ':' . $second;

return $postdate;

}
add_filter( 'umed_postdate', 'umed_postdate_from_filename', 10, 2 );

外掛標籤

開發者團隊

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

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

原文外掛簡介

Register image to media library

Change to the date/time of EXIF information.

Sibling plugin

Exif Caption.
Exif Details.

Sample of how to use the filter hook

Sample snippet

/** ==================================================
* Sample snippet for Upload Media Exif Date
*
* The original filter hook('umed_postdate'),
* Get the date and time from the file name when the date and time cannot be read from the EXIF.
*
* @param string $postdate postdate.
* @param string $filename filename.
*/
function umed_postdate_from_filename( $postdate, $filename ) {

/* Sample for 20191120_183022.jpg */
$year = substr( $filename, 0, 4 );
$month = substr( $filename, 4, 2 );
$day = substr( $filename, 6, 2 );
$hour = substr( $filename, 9, 2 );
$minute = substr( $filename, 11, 2 );
$second = substr( $filename, 13, 2 );

$postdate = $year . '-' . $month . '-' . $day . ' ' . $hour . ':' . $minute . ':' . $second;

return $postdate;

}
add_filter( 'umed_postdate', 'umed_postdate_from_filename', 10, 2 );

延伸相關外掛

文章
Filter
Apply Filters
Mastodon