/** * For use in the get_the_image plugin from the framework. Returns the remote video thumbnail URL for a given post */ public static function gettheimage_url($post_id) { $post_id = intval($post_id); if (empty($post_id) || $post_id < 1) { return false; } $embed_code = get_post_meta($post_id, 'wpzoom_post_embed_code', true); if (empty($embed_code)) { return false; } $url = parent::extract_url_from_embed(trim($embed_code)); if ($url === false) { return false; } $size = class_exists('option') && in_array(option::get('video_api_size'), array('Small', 'Medium', 'Large')) ? strtolower('' . option::get('video_api_size')) : null; $attachment_id = self::attach_remote_video_thumb($url, $post_id, $size); if ($attachment_id === false || $attachment_id < 1) { return false; } $attachment_image_src = wp_get_attachment_image_src($attachment_id); return $attachment_image_src !== false && is_array($attachment_image_src) && isset($attachment_image_src[0]) && !empty($attachment_image_src[0]) ? array('src' => '' . $attachment_image_src[0]) : false; }
public function sliderthumb_get() { if (isset($_POST['wpzoom_sliderthumb_embedcode']) && isset($_POST['wpzoom_sliderthumb_postid'])) { $url = WPZOOM_Video_API::extract_url_from_embed(trim(stripslashes($_POST['wpzoom_sliderthumb_embedcode']))); $postid = intval($_POST['wpzoom_sliderthumb_postid']); if (empty($url) || filter_var($url, FILTER_VALIDATE_URL) === false || $postid < 1) { wp_send_json_error(); } $thumb_url = WPZOOM_Video_Thumb::fetch_video_thumbnail($url, $postid); header('Content-type: application/json'); if ($thumb_url === false) { wp_send_json_error(); } else { wp_send_json_success($thumb_url); } } }
/** * For use in the get_the_image plugin from the framework. Returns the remote video thumbnail URL for a given post */ public static function gettheimage_url($post_id) { $post_id = intval($post_id); if (empty($post_id) || $post_id < 1) { return false; } $embed_code = get_post_meta($post_id, 'wpzoom_post_embed_code', true); if (empty($embed_code)) { return false; } $url = parent::extract_url_from_embed(trim($embed_code)); if ($url === false) { return false; } $fetch = self::fetch_video_thumbnail($url, $post_id); return $fetch !== false && isset($fetch['thumb_url']) && !empty($fetch['thumb_url']) ? array('src' => $fetch['thumb_url']) : false; }