将图像从禅车迁移到Wordpress,现在正确的图像已经存在,但是WP认为每个图像的尺寸都是100 x 100。
如果我使用WP图像编辑器并在图像中做一些微小的更改,维度将被更新到正确的维度。
这个有用的MySQL查询有用的MySQL查询:
SELECT * FROM `wp_postmeta` WHERE meta_key IN ('_wp_attached_file', '_wp_attachment_backup_sizes', '_wp_attachment_metadata', '_thumbnail_id');显示图像“维度”存储在_wp_attachment_metadata中。例如,(非串行化):
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' => '',
),
)找到了这个方便的来自图像魔术的命令行工具,它确认了实际的图像尺寸:
$ 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的地理尺寸更新所有相关的_wp_attachment_metadata列。
将元数据更新到实际图像维度的好方法是什么?
发布于 2017-09-02 06:59:26
您可以很容易地对所有图像使用再生指甲和批量重新生成。再生缩略图插件更新所有细节的全尺寸图像,以及它重新创建缩略图。它将更新每个图像的维度,但是所有其他图像大小也应该被注册,否则它们将不会存储在更新的图像元中。
如果您只想更新全尺寸图像的尺寸,您可能可以运行一个自定义脚本。
阅读您共享的链接,并检查重新生成缩略图的代码,最新版本似乎不依赖WordPress存储在图像元中的维度,但是对于缩略图,它肯定需要图像元,所有的图像大小都应该注册。
https://wordpress.stackexchange.com/questions/278871
复制相似问题