Tribe__Events__Aggregator__Record__Abstract::import_image( array $data )

Imports the image contained in the post data image field if any.


Parameters

$data

(array) (Required) A post data in array format.


Top ↑

Return

(object|bool) An object with the image post ID or false on failure.


Top ↑

Source

File: src/Tribe/Aggregator/Record/Abstract.php

	public function import_image( $data ) {
		if (
			empty( $data['image'] )
			|| ! (
				filter_var( $data['image'], FILTER_VALIDATE_URL )
				|| filter_var( $data['image'], FILTER_VALIDATE_INT )
			)
		) {
			return false;
		}

		$uploader = new Tribe__Image__Uploader( $data['image'] );
		$thumbnail_id = $uploader->upload_and_get_attachment_id();

		return false !== $thumbnail_id ? (object) array( 'post_id' => $thumbnail_id ) : false;
	}