将图像从Zen Cart迁移到Wordpress,现在有了正确的图像,但WP认为每个图像的尺寸都是100 x 100。
如果我使用WP图像编辑器并对图像进行细微更改,尺寸将更新为正确的尺寸。
这helpful MySQL query:
SELECT * FROM `wp_postmeta` WHERE meta_key IN (\'_wp_attached_file\', \'_wp_attachment_backup_sizes\', \'_wp_attachment_metadata\', \'_thumbnail_id\');
显示图像“尺寸”存储在
_wp_attachment_metadata
. 例如(
unserialized):
array (
\'width\' => 100,
\'height\' => 100,
\'hwstring_small\' => \'height=100 width=100\',
\'file\' => \'2017/09/p-72-Digital-Boardwalk2.jpg\',
\'sizes\' =>
array (
\'thumbnail\' =>
array (
\'file\' => \'p-72-Digital-Boardwalk2.jpg\',
\'width\' => 150,
\'height\' => 150,
),
\'medium\' =>
array (
\'file\' => \'p-72-Digital-Boardwalk2.jpg\',
\'width\' => 300,
\'height\' => 214,
),
\'shop_thumbnail\' =>
array (
\'file\' => \'p-72-Digital-Boardwalk2.jpg\',
\'width\' => 90,
\'height\' => 67,
),
\'shop_catalog\' =>
array (
\'file\' => \'p-72-Digital-Boardwalk2.jpg\',
\'width\' => 150,
\'height\' => 111,
),
\'shop_single\' =>
array (
\'file\' => \'p-72-Digital-Boardwalk2.jpg\',
\'width\' => 300,
\'height\' => 250,
),
),
\'image_meta\' =>
array (
\'aperture\' => 0,
\'credit\' => \'\',
\'camera\' => \'\',
\'caption\' => \'\',
\'created_timestamp\' => 0,
\'copyright\' => \'\',
\'focal_length\' => 0,
\'iso\' => 0,
\'shutter_speed\' => 0,
\'title\' => \'\',
),
)
发现这个很方便
command line tool from ImageMagic 确认实际图像尺寸:
$ identify p-72-Digital-Boardwalk2.jpg
p-72-Digital-Boardwalk2.jpg JPEG 960x960 960x960+0+0 8-bit DirectClass 69KB 0.000u 0:00.009
我可以编写一个脚本来遍历所有媒体库文件,并可能使用php的
getimagesize, 更新所有相关
_wp_attachment_metadata
列。
将元数据更新为实际图像维度的好方法是什么?