I want to detach/unattach an image from the page it's currently attached to -- by using PHP, instead of the "Detach" link in the Media Library.
I found this (in /wp-admin/includes/media.php#3164):
$result = $wpdb->query( "UPDATE $wpdb->posts SET post_parent = 0 WHERE post_type = 'attachment' AND ID IN ( $ids_string )" );
So I assume I could just use this in my own PHP, replacing the
$ids_string with the ID of the attachment to remove.
Is there a better way?