function ajax_get_image_id()
{
if (!$this->configured()) {
$this->ajax_error(__('Plugin not configured', 'ooyala'));
}
// check nonce
$this->ajax_check();
$post_id = (int) filter_input(INPUT_POST, 'post_id', FILTER_VALIDATE_INT);
$url = filter_input(INPUT_POST, 'image_url', FILTER_SANITIZE_URL);
// sanity check inputs
if (empty($url)) {
$this->ajax_error(__('No image URL given', 'ooyala'));
}
// First check that we haven't already downloaded this image.
$existing_id = $this->get_attachment_id($url);
$this->ajax_success(__('Found attachment ID', 'ooyala'), array('id' => $existing_id));
}