Unfortunately, our current version doesn’t store images as featured images. But, this is already on our TODO lists. So, we will have this very soon.
As a quick solution, we have prepared a patch for you. Kindly try adding the following code to the bottom of your theme’s functions.php file.
function aiovg_custom_init() {
add_post_type_support( 'aiovg_videos', 'thumbnail' );
}
add_action( 'init', 'aiovg_custom_init', 11 );
// Works on OLD posts
function aiovg_set_featured_images() {
if ( false == get_option( 'aiovg_featured_images_inserted' ) ) {
add_option( 'aiovg_featured_images_inserted', 1 );
$items = get_posts( array( 'post_type' => 'aiovg_videos', 'post_status' => 'any', 'numberposts' => -1, 'fields' => 'ids' ) );
if ( count( $items ) ) {
foreach ( $items as $item ) {
$image_id = get_post_meta( $item->ID, 'image_id', true );
if ( (int) $image_id > 0 ) {
set_post_thumbnail( $item->ID, $image_id );
}
}
}
}
}
add_action( 'init', 'aiovg_set_featured_images' );
// Works on NEW posts
function aiovg_custom_save_featured_image( $post_id, $post ) {
if ( ! isset( $_POST['post_type'] ) ) {
return $post_id;
}
// Check this is the "aiovg_videos" custom post type
if ( 'aiovg_videos' != $post->post_type ) {
return $post_id;
}
// If this is an autosave, our form has not been submitted, so we don't want to do anything
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
return $post_id;
}
// Check if "aiovg_video_sources_nonce" nonce is set
if ( isset( $_POST['aiovg_video_sources_nonce'] ) ) {
// Verify that the nonce is valid
if ( wp_verify_nonce( $_POST['aiovg_video_sources_nonce'], 'aiovg_save_video_sources' ) ) {
$image_id = get_post_meta( $post_id, 'image_id', true );
if ( (int) $image_id > 0 ) {
set_post_thumbnail( $post_id, $image_id );
}
}
}
return $post_id;
}
add_action( 'save_post', 'aiovg_custom_save_featured_image', 99, 2 );
Hope this solved your issue!