0

000 "_wp_attachment_metadata" in mySQL for about 50k images on my blog and it's slowing down my WP site significantly.

I've checked the field and found it contain almost nothing significant .. most looked like blanks.

Example:

a:5:{s:5:"width";i:500;s:6:"height";i:750;s:4:"file";s:21:"2013/10/698-thumb.jpg";s:5:"sizes";a:2:{s:9:"thumbnail";a:4:{s:4:"file";s:21:"698-thumb-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:21:"698-thumb-200x300.jpg";s:5:"width";i:200;s:6:"height";i:300;s:9:"mime-type";s:10:"image/jpeg";}}s:10:"image_meta";a:10:{s:8:"aperture";i:0;s:6:"credit";s:0:"";s:6:"camera";s:0:"";s:7:"caption";s:0:"";s:17:"created_timestamp";i:0;s:9:"copyright";s:0:"";s:12:"focal_length";i:0;s:3:"iso";i:0;s:13:"shutter_speed";i:0;s:5:"title";s:0:"";}}

Hence I want to either

  • remove them
  • remove the values
  • trim down string

But I am not sure how .. and also how to do it. Hope someone can help me with this.

Thanks in advance :)

Edmund Fong
  • 101
  • 1

1 Answers1

0
<?php delete_post_meta_by_key( '_wp_attachment_metadata' ); ?>

Delete all the meta data with the specific key

mujuonly
  • 11,370
  • 5
  • 45
  • 75
  • Will it cause any problem to delete the entire contents?? Since it does contain the "width" and "height" details? – Edmund Fong Jun 10 '17 at 16:19
  • @EdmundFong You can re-generate thumbnails if anything is missed with https://wordpress.org/plugins/regenerate-thumbnails/. – mujuonly Jun 10 '17 at 16:29