內容簡介
將圖像註冊到媒體庫
將 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 );
外掛標籤
開發者團隊
原文外掛簡介
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 );
