src/model/admin/class-image.php
public function set_images( $post_id ) {

		if ( ! $post_id || is_null( $post_id ) ) {
			return 0; }

		update_post_meta( $post_id, 'custom_images_grifus', 'true' );
		$count  = 0;
		$tmdb   = 'image.tmdb.org';
		$poster = get_post_meta( $post_id, 'poster_url', true );

		if ( filter_var( $poster, FILTER_VALIDATE_URL ) && strpos( $poster, $tmdb ) ) {
			$count++;
			$poster = WP_Image::save( $poster, $post_id, true );
			update_post_meta( $post_id, 'poster_url', $poster );
		}

		$main = get_post_meta( $post_id, 'fondo_player', true );

		if ( filter_var( $main, FILTER_VALIDATE_URL ) && strpos( $main, $tmdb ) ) {
			$count++;
			$main = WP_Image::save( $main, $post_id );
			update_post_meta( $post_id, 'fondo_player', $main );
		}

		$images       = get_post_meta( $post_id, 'imagenes', true );
		$images_array = explode( "\n", $images );
		$new_images   = '';

		foreach ( $images_array as $image ) {
			$image = trim( $image );
			if ( filter_var( $image, FILTER_VALIDATE_URL ) && strpos( $image, $tmdb ) ) {
				$count++;
				$url = WP_Image::save( $image, $post_id );

				$new_images .= $url . "\n";
			}
		}

		if ( ! empty( $new_images ) ) {
			update_post_meta( $post_id, 'imagenes', $new_images );
		}

		return $count;
	}
public function set_images( $post_id ) {

		if ( ! $post_id || is_null( $post_id ) ) {
			return 0; }

		update_post_meta( $post_id, 'custom_images_grifus', 'true' );
		$count  = 0;
		$tmdb   = 'image.tmdb.org';
		$poster = get_post_meta( $post_id, 'poster_url', true );

		if ( filter_var( $poster, FILTER_VALIDATE_URL ) && strpos( $poster, $tmdb ) ) {
			$count++;
			$poster = WP_Image::save( $poster, $post_id, true );
			update_post_meta( $post_id, 'poster_url', $poster );
		}

		$main = get_post_meta( $post_id, 'fondo_player', true );

		if ( filter_var( $main, FILTER_VALIDATE_URL ) && strpos( $main, $tmdb ) ) {
			$count++;
			$main = WP_Image::save( $main, $post_id );
			update_post_meta( $post_id, 'fondo_player', $main );
		}

		$images       = get_post_meta( $post_id, 'imagenes', true );
		$images_array = explode( "\n", $images );
		$new_images   = '';

		foreach ( $images_array as $image ) {
			$image = trim( $image );
			if ( filter_var( $image, FILTER_VALIDATE_URL ) && strpos( $image, $tmdb ) ) {
				$count++;
				$url = WP_Image::save( $image, $post_id );

				$new_images .= $url . "\n";
			}
		}

		if ( ! empty( $new_images ) ) {
			update_post_meta( $post_id, 'imagenes', $new_images );
		}

		return $count;
	}
Find IMDB images, save them and replace them in posts.

@param int $post_id → post id.

@return string → posts edited number