function get_attachment_id($url)
{
// Though this is a query on postmeta, it's only invoked by administrative
// users on a relatively infrequent basis
$query = new WP_Query(array('post_type' => 'attachment', 'meta_query' => array(array('key' => 'ooyala_source', 'value' => $url)), 'post_status' => 'any', 'fields' => 'ids', 'posts_per_page' => 1));
return $query->posts ? $query->posts[0] : 0;
}