public function update_videopress_info($vp_info)
{
$errors = null;
foreach ($vp_info as $vp_item) {
$id = $vp_item['post_id'];
$guid = $vp_item['guid'];
$attachment = get_post($id);
if (!$attachment) {
$errors[] = array('id' => $id, 'error' => 'Post not found');
continue;
}
$attachment->guid = $vp_item['original'];
$attachment->file = $vp_item['original'];
wp_update_post($attachment);
// Update the vp guid and set it to a direct meta property.
update_post_meta($id, 'videopress_guid', $guid);
$meta = wp_get_attachment_metadata($attachment->ID);
$current_poster = get_post_meta($id, '_thumbnail_id');
$meta['width'] = $vp_item['width'];
$meta['height'] = $vp_item['height'];
$meta['original']['url'] = $vp_item['original'];
$meta['videopress'] = $vp_item;
$meta['videopress']['url'] = 'https://videopress.com/v/' . $guid;
if (!$current_poster && isset($vp_item['poster']) && !empty($vp_item['poster'])) {
$thumbnail_id = videopress_download_poster_image($vp_item['poster'], $id);
update_post_meta($id, '_thumbnail_id', $thumbnail_id);
}
wp_update_attachment_metadata($attachment->ID, $meta);
// update the meta to tell us that we're processing or complete
update_post_meta($id, 'videopress_status', videopress_is_finished_processing($attachment->ID) ? 'complete' : 'processing');
}
if (count($errors) > 0) {
return array('errors' => $errors);
} else {
return true;
}
}