当PDF预览图像可用时,媒体库如何确定需要显示它们?它是否检查Posteta表中的“\\u wp\\u attachment\\u metadata”记录?Wordpress中执行此操作的代码在哪里?
媒体库如何确定PDF文件是否包含预览图像?
1 个回复
最合适的回答,由SO网友:birgire 整理而成
PDF文档的预览图像创建于wp_generate_attachment_metadata()
[src].
全尺寸预览图像将具有-pdf.jpg
扩展[src].
PDF文档的预览图像信息存储在_wp_attachment_metadata
在post meta表中。
下面是一个示例数据test.pdf
文件:
Array
(
[0] => Array
(
[sizes] => Array
(
[thumbnail] => Array
(
[file] => test-pdf-116x150.jpg
[width] => 116
[height] => 150
[mime-type] => image/jpeg
)
[full] => Array
(
[file] => test-pdf.jpg
[width] => 1088
[height] => 1408
[mime-type] => image/jpeg
)
)
)
)
这将作为序列化数组存储在_wp_attachment_metadata
键,但为了更好的可读性,我们在这里将其显示为数组。它是用wp_get_attachment_metadata()
[src], 对于任何其他图像附件。
我们可以在中看到它wp_prepare_attachment_for_js()
[src].
也在image_downsize()
[src], 用于wp_get_attachment_image_src()
[src].
后者用于wp_get_attachment_image()
, 这叫做column_title()
媒体列表表的方法,用于显示图像预览[src].
希望有帮助!
结束