Attachement Meta DATA

时间:2019-02-18 作者:ADP Software

我们尝试将我们的管理软件连接到Wordpress/Woocommerce。

我们的客户可以直接从我们的软件编辑和管理产品、库存和类别。

Wordpress数据库很简单,所以我们很容易达到我们的目标。

剩下的唯一问题是“图像管理”。

我们的主要问题是wp\\u attachment\\u元数据:

a:5:{s:5:"width";i:910;s:6:"height";i:607;s:4:"file";s:10:"t-logo.jpg";s:5:"sizes";a:15:{s:9:"thumbnail";a:4:{s:4:"file";s:18:"t-logo-300x300.jpg";s:5:"width";i:300;s:6:"height";i:300;s:9:"mime-type";s:10:"image/jpeg";}s:6:"medium";a:4:{s:4:"file";s:18:"t-logo-600x600.jpg";s:5:"width";i:600;s:6:"height";i:600;s:9:"mime-type";s:10:"image/jpeg";}s:12:"medium_large";a:4:{s:4:"file";s:18:"t-logo-768x512.jpg";s:5:"width";i:768;s:6:"height";i:512;s:9:"mime-type";s:10:"image/jpeg";}s:5:"large";a:4:{s:4:"file";s:18:"t-logo-910x448.jpg";s:5:"width";i:910;s:6:"height";i:448;s:9:"mime-type";s:10:"image/jpeg";}s:19:"yith_wcbr_logo_size";a:4:{s:4:"file";s:16:"t-logo-45x30.jpg";s:5:"width";i:45;s:6:"height";i:30;s:9:"mime-type";s:10:"image/jpeg";}s:24:"yith_wcbr_grid_logo_size";a:4:{s:4:"file";s:16:"t-logo-90x60.jpg";s:5:"width";i:90;s:6:"height";i:60;s:9:"mime-type";s:10:"image/jpeg";}s:17:"raworganic-medium";a:4:{s:4:"file";s:18:"t-logo-680x380.jpg";s:5:"width";i:680;s:6:"height";i:380;s:9:"mime-type";s:10:"image/jpeg";}s:15:"raworganic-blog";a:4:{s:4:"file";s:18:"t-logo-680x453.jpg";s:5:"width";i:680;s:6:"height";i:453;s:9:"mime-type";s:10:"image/jpeg";}s:21:"woocommerce_thumbnail";a:5:{s:4:"file";s:18:"t-logo-300x300.jpg";s:5:"width";i:300;s:6:"height";i:300;s:9:"mime-type";s:10:"image/jpeg";s:9:"uncropped";b:1;}s:18:"woocommerce_single";a:4:{s:4:"file";s:18:"t-logo-600x400.jpg";s:5:"width";i:600;s:6:"height";i:400;s:9:"mime-type";s:10:"image/jpeg";}s:29:"woocommerce_gallery_thumbnail";a:4:{s:4:"file";s:18:"t-logo-250x361.jpg";s:5:"width";i:250;s:6:"height";i:361;s:9:"mime-type";s:10:"image/jpeg";}s:12:"shop_catalog";a:4:{s:4:"file";s:18:"t-logo-300x300.jpg";s:5:"width";i:300;s:6:"height";i:300;s:9:"mime-type";s:10:"image/jpeg";}s:11:"shop_single";a:4:{s:4:"file";s:18:"t-logo-600x400.jpg";s:5:"width";i:600;s:6:"height";i:400;s:9:"mime-type";s:10:"image/jpeg";}s:14:"shop_thumbnail";a:4:{s:4:"file";s:18:"t-logo-250x361.jpg";s:5:"width";i:250;s:6:"height";i:361;s:9:"mime-type";s:10:"image/jpeg";}s:14:"shop_magnifier";a:4:{s:4:"file";s:18:"t-logo-600x600.jpg";s:5:"width";i:600;s:6:"height";i:600;s:9:"mime-type";s:10:"image/jpeg";}}s:10:"image_meta";a:12:{s:8:"aperture";s:1:"0";s:6:"credit";s:0:"";s:6:"camera";s:0:"";s:7:"caption";s:0:"";s:17:"created_timestamp";s:1:"0";s:9:"copyright";s:0:"";s:12:"focal_length";s:1:"0";s:3:"iso";s:1:"0";s:13:"shutter_speed";s:1:"0";s:5:"title";s:0:"";s:11:"orientation";s:1:"0";s:8:"keywords";a:0:{}}} 
我们无法为图像生成此数据,因为我们无法理解这些值:

a:5....s:12....s:9

这个元改变了每个图像。

你知道这个字段代表什么吗?

谢谢

2 个回复
SO网友:Antti Koskinen

这是序列化格式的附件数据。在wp_get_attachment_metadata 法典条目。

如果您有一些自定义功能来进行图像上传,那么可以使用wp_generate_attachment_metadata 生成该数据。

SO网友:troxxx

wp\\u attachment\\u元数据包含序列化数组。您必须将数据取消序列化为JSON格式(例如),您将了解一切;)

以下是PHP数组格式的代码:

array (
  \'width\' => 910,
  \'height\' => 607,
  \'file\' => \'t-logo.jpg\',
  \'sizes\' => 
  array (
    \'thumbnail\' => 
    array (
      \'file\' => \'t-logo-300x300.jpg\',
      \'width\' => 300,
      \'height\' => 300,
      \'mime-type\' => \'image/jpeg\',
    ),
    \'medium\' => 
    array (
      \'file\' => \'t-logo-600x600.jpg\',
      \'width\' => 600,
      \'height\' => 600,
      \'mime-type\' => \'image/jpeg\',
    ),
    \'medium_large\' => 
    array (
      \'file\' => \'t-logo-768x512.jpg\',
      \'width\' => 768,
      \'height\' => 512,
      \'mime-type\' => \'image/jpeg\',
    ),
    \'large\' => 
    array (
      \'file\' => \'t-logo-910x448.jpg\',
      \'width\' => 910,
      \'height\' => 448,
      \'mime-type\' => \'image/jpeg\',
    ),
    \'yith_wcbr_logo_size\' => 
    array (
      \'file\' => \'t-logo-45x30.jpg\',
      \'width\' => 45,
      \'height\' => 30,
      \'mime-type\' => \'image/jpeg\',
    ),
    \'yith_wcbr_grid_logo_size\' => 
    array (
      \'file\' => \'t-logo-90x60.jpg\',
      \'width\' => 90,
      \'height\' => 60,
      \'mime-type\' => \'image/jpeg\',
    ),
    \'raworganic-medium\' => 
    array (
      \'file\' => \'t-logo-680x380.jpg\',
      \'width\' => 680,
      \'height\' => 380,
      \'mime-type\' => \'image/jpeg\',
    ),
    \'raworganic-blog\' => 
    array (
      \'file\' => \'t-logo-680x453.jpg\',
      \'width\' => 680,
      \'height\' => 453,
      \'mime-type\' => \'image/jpeg\',
    ),
    \'woocommerce_thumbnail\' => 
    array (
      \'file\' => \'t-logo-300x300.jpg\',
      \'width\' => 300,
      \'height\' => 300,
      \'mime-type\' => \'image/jpeg\',
      \'uncropped\' => true,
    ),
    \'woocommerce_single\' => 
    array (
      \'file\' => \'t-logo-600x400.jpg\',
      \'width\' => 600,
      \'height\' => 400,
      \'mime-type\' => \'image/jpeg\',
    ),
    \'woocommerce_gallery_thumbnail\' => 
    array (
      \'file\' => \'t-logo-250x361.jpg\',
      \'width\' => 250,
      \'height\' => 361,
      \'mime-type\' => \'image/jpeg\',
    ),
    \'shop_catalog\' => 
    array (
      \'file\' => \'t-logo-300x300.jpg\',
      \'width\' => 300,
      \'height\' => 300,
      \'mime-type\' => \'image/jpeg\',
    ),
    \'shop_single\' => 
    array (
      \'file\' => \'t-logo-600x400.jpg\',
      \'width\' => 600,
      \'height\' => 400,
      \'mime-type\' => \'image/jpeg\',
    ),
    \'shop_thumbnail\' => 
    array (
      \'file\' => \'t-logo-250x361.jpg\',
      \'width\' => 250,
      \'height\' => 361,
      \'mime-type\' => \'image/jpeg\',
    ),
    \'shop_magnifier\' => 
    array (
      \'file\' => \'t-logo-600x600.jpg\',
      \'width\' => 600,
      \'height\' => 600,
      \'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 (
    ),
  ),
);