This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness.

Image_Import::import_from_api()


Return

(array|bool)


Source

File: includes/libs/image-import.class.php

	private function import_from_api(){
		$q = new Video_Import( 'thumbnails', $this->video_post->video_id );
		$thumbnails = $q->get_feed();
		if( $thumbnails ){

			$exists = $this->check_duplicate( $thumbnails['uri'] );

			if( $exists ){

				Helper::debug_message(
					sprintf(
						'While importing thumbnail from Vimeo API, a duplicate image with ID #%s was found. Setting duplicate as featured image for post #%s.',
						$exists->ID,
						$this->video_post->get_post()->ID
					)
				);

				set_post_thumbnail( $this->video_post->get_post()->ID, $exists->ID);

				return [
					'post_id' => $this->video_post->get_post()->ID,
					'attachment_id' => $exists->ID
				];

			}else{
				$img    = end( $thumbnails['images'] );
				$result = $this->import_to_media( $img );

				if ( isset( $result['attachment_id'] ) ) {

					Helper::debug_message(
						sprintf(
							'Imported image ID #%s from Vimeo API and set it as featured image for post ID #%s.',
							$result['attachment_id'],
							$result['post_id']
						)
					);

					update_post_meta(
						$result['attachment_id'],
						'__vimeo_image_uri',
						$thumbnails['uri']
					);
				}

				return $result;
			}
		}
	}

Start your video site now!

Manage and coordinate your Vimeo channels, albums or videos with your WordPress website. Perfect fit for membership, portfolio, online courses or any type of video collection.

Get Vimeotheque PRO!