Increase memory limit when processing AJAX actions.

On a large network with many images, database queries were
failing with an out of memory error.
Process all images; not just those attached to a post.
Delete attachment if no [gallery] shortcode is present in post_content