当我运行以下代码以返回给定图像的所有附件图像元数据时,我看到所有配置的图像大小都显示原始图像文件名,而不是调整大小/裁剪的文件名。这些文件确实存在于上传目录中。
<?php
echo'<pre>';
print_r(wp_get_attachment_metadata( $image_id ));
echo'</pre>';
?>
从上面得到的数组:
Array(
[width] => 1536
[height] => 2048
[file] => 2020/08/test.jpg
[sizes] => Array
(
[medium] => Array
(
[file] => test.jpg
[width] => 225
[height] => 300
[mime-type] => image/jpeg
)
[large] => Array
(
[file] => test.jpg
[width] => 768
[height] => 1024
[mime-type] => image/jpeg
)
[thumbnail] => Array
(
[file] => test.jpg
[width] => 150
[height] => 150
[mime-type] => image/jpeg
)
[medium_large] => Array
(
[file] => test.jpg
[width] => 768
[height] => 1024
[mime-type] => image/jpeg
)
[1536x1536] => Array
(
[file] => test.jpg
[width] => 1152
[height] => 1536
[mime-type] => image/jpeg
)
[woocommerce_thumbnail] => Array
(
[file] => test.jpg
[width] => 300
[height] => 225
[mime-type] => image/jpeg
[uncropped] =>
)
[woocommerce_single] => Array
(
[file] => test.jpg
[width] => 1200
[height] => 900
[mime-type] => image/jpeg
)
[woocommerce_gallery_thumbnail] => Array
(
[file] => test.jpg
[width] => 200
[height] => 200
[mime-type] => image/jpeg
)
[shop_catalog] => Array
(
[file] => test.jpg
[width] => 300
[height] => 225
[mime-type] => image/jpeg
)
[shop_single] => Array
(
[file] => test.jpg
[width] => 1200
[height] => 900
[mime-type] => image/jpeg
)
[shop_thumbnail] => Array
(
[file] => test.jpg
[width] => 200
[height] => 200
[mime-type] => image/jpeg
)
)
[image_meta] => Array
(
[aperture] => 0
[credit] =>
[camera] =>
[caption] =>
[created_timestamp] => 0
[copyright] =>
[focal_length] => 0
[iso] => 0
[shutter_speed] => 0
[title] =>
[orientation] => 0
[keywords] => Array
(
)
)
[original_image] => test.jpg
)
我尝试使用重新生成缩略图插件,虽然它确实重新创建了各种图像文件,但它似乎并没有更新存储在wp_postmeta该附件的数据库表中的内容。元数据中的所有宽度和高度值都是正确的。
重新创建缩略图后,我还尝试将图像分离并重新附加到帖子以及上传全新的图像。所有人都面临同样的问题。
感激地收到任何帮助。
我们正在使用:
- WordPress 5.5.4
- WooCommerce 4.4.1
- 奥尔斯顿主题