/** * Get thumbnails of video * * @since 1.0 * @param integer $post_id * * @return array */ function rtmedia_transcoding_get_video_thumbs($post_id) { return maybe_unserialize(get_post_meta($post_id, rtmedia_transcoding_get_video_thumb_meta_key(), true)); }
/** * Save thumbnails of media from transcoding server * * @since 1.0 */ public function save_media_thumbnails($post_id, $thumbs) { // those thumbs may be in serialize form $thumbs = maybe_unserialize($thumbs); if (!empty($thumbs) && is_array($thumbs)) { $post_thumbs = array(); // loop through each thumb and save them foreach ($thumbs as $single_thumb) { // get thumb from remote $remote_thumb = wp_remote_get($single_thumb); $thumb_body = wp_remote_retrieve_body($remote_thumb); // generate thumb file name $thumb_info = pathinfo($single_thumb); $thumb_file_name = basename(urldecode($thumb_info['basename'])); // upload thumb file $thumb_upload_info = wp_upload_bits($thumb_file_name, null, $thumb_body); $post_thumbs[] = $thumb_upload_info['url']; } // save media thumb details into post meta update_post_meta($post_id, rtmedia_transcoding_get_video_thumb_meta_key(), $post_thumbs); } }