我们去看看吧。如果我在dev install中获取任意附件并转储其post对象和自定义字段,我会得到以下结果:
object WP_Post (24) {
public ID -> integer 1687
public post_author -> string (1) "1"
public post_date -> string (19) "2013-09-18 14:37:07"
public post_date_gmt -> string (19) "2013-09-18 21:37:07"
public post_content -> string (0) ""
public post_title -> string (24) "dsc20050604_133440_34211"
public post_excerpt -> string (0) ""
public post_status -> string (7) "inherit"
public comment_status -> string (4) "open"
public ping_status -> string (6) "closed"
public post_password -> string (0) ""
public post_name -> string (24) "dsc20050604_133440_34211"
public to_ping -> string (0) ""
public pinged -> string (0) ""
public post_modified -> string (19) "2013-09-18 14:37:07"
public post_modified_gmt -> string (19) "2013-09-18 21:37:07"
public post_content_filtered -> string (0) ""
public post_parent -> integer 0
public guid -> string (76) "http://dev.rarst.net/wp-content/uploads/2013/09/dsc20050604_133440_34211.jpg"
public menu_order -> integer 0
public post_type -> string (10) "attachment"
public post_mime_type -> string (10) "image/jpeg"
public comment_count -> string (1) "0"
public filter -> string (3) "raw"
}
array(2) [
\'_wp_attached_file\' => array(1) [
string (36) "2013/09/dsc20050604_133440_34211.jpg"
]
\'_wp_attachment_metadata\' => array(1) [
string (687) "a:5:{s:5:"width";i:640;s:6:"height";i:480;s:4:"file";s:36:"2013/09/dsc20050604_133440_34211.jpg";s:5:"sizes";a:2:{s:9:"thumbnail";a:4:{s:4:"file";s:36:"dsc20050604_133440_34211-150x150.jpg";s:5:"width";i:150;s:6:"height";i:150;s:9:"mime-type";s:10:"image/jpeg";}s:6:"medium";a:4:{s:4:"file";s:36:"dsc20050604_133440_34211-300x225.jpg";s:5:"width";i:300;s:6:"height";i:225;s:9:"mime-type";s:10:"image/jpeg";}}s:10:"image_meta";a:10:{s:8:"aperture";d:2;s:6:"credit";s:0:"";s:6:"camera";s:9:"CYBERSHOT";s:7:"caption";s:0:"";s:17:"created_timestamp";i:1117892080;s:9:"copyright";s:0:"";s:12:"focal_length";s:3:"9.7";s:3:"iso";s:3:"100";s:13:"shutter_speed";s:6:"0.0125";s:5:"title";s:0:"";}}"
]
]
要点分别针对您的问题:
在guid
字段执行not 重要的是,它保存了一个计算URL的副本(但在WP上下文中,它并不是可靠的URL),大多数情况下应该被忽略主文件和大小之间的关系存储在自定义元字段中简单替换将not 工作,它将破坏中的序列化字符串_wp_attachment_metadata
元字段。您需要支持序列化的搜索/替换工具,有很多(WP CLI、search replace DB等)