Skip to content

Instantly share code, notes, and snippets.

@linuslundahl
Created November 28, 2010 19:27
Show Gist options
  • Save linuslundahl/719225 to your computer and use it in GitHub Desktop.
Save linuslundahl/719225 to your computer and use it in GitHub Desktop.
Remove generated attachment thumbnails from wordpress database.
global $wpdb;
$query = "SELECT meta_value, meta_id FROM $wpdb->postmeta WHERE meta_key = '_wp_attachment_metadata'";
$result = $wpdb->get_results($query);
foreach ($result as $item) {
$meta = unserialize($item->meta_value);
unset($meta['sizes']);
$wpdb->update( 'wp_vira_postmeta', array('meta_value' => serialize($meta)), array('meta_id' => $item->meta_id) );
}
@max-kk
Copy link

max-kk commented Oct 12, 2016

By idea 'wp_vira_postmeta' need replace to $wpdb->postmeta

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment