当前Wordpress从图像的exif标题值中获取附件名称:
<?php
// Use image exif/iptc data for title and caption defaults if possible.
} elseif ( 0 === strpos( $type, \'image/\' ) && $image_meta = wp_read_image_metadata( $file ) ) {
if ( trim( $image_meta[\'title\'] ) && ! is_numeric( sanitize_title( $image_meta[\'title\'] ) ) ) {
$title = $image_meta[\'title\'];
}
有没有办法将原始文件名保存到数据库中?我尝试了很多过滤器和挂钩,但没有任何结果。https://developer.wordpress.org/reference/functions/media_handle_upload/
Possible solution 可以使用sanitize\\u file\\u name过滤器获取$filename\\u raw,并将其插入到具有已清理$filename的自定义表中。为了稍后获得原始文件名,我们只需要在比较经过清理的文件名和附件文件名时查询自定义表。
我说得对吗?或者还有其他方法吗?