src/model/admin/class-image.php
public function replace_old_images() {

		global $wpdb;

		$response = [
			'post_id'      => 0,
			'post_title'   => '',
			'images_added' => 0,
		];

		$post_table = $wpdb->prefix . 'posts';

		$postmeta_table = $wpdb->prefix . 'postmeta';

		$query = "
            SELECT     ID, post_title
            FROM       $post_table
            INNER JOIN $postmeta_table 
            ON         $post_table.ID = $postmeta_table.post_id
            WHERE      $post_table.post_type = 'post'
            AND        $post_table.post_status = 'publish'
            AND        $postmeta_table.meta_key = 'custom_images_grifus'
            AND        $postmeta_table.meta_value = 'false'
            ORDER BY   $post_table.ID ASC
        ";

		$post = $wpdb->get_row( $query );

		if ( ! is_null( $post ) && isset( $post->ID ) && isset( $post->post_title ) ) {
			$post_id = $post->ID;

			$images_added = $this->set_images( $post->ID );

			$response = [
				'post_id'      => $post->ID,
				'post_title'   => $post->post_title,
				'images_added' => $images_added,
			];
		}

		return $response;
	}
public function replace_old_images() {

		global $wpdb;

		$response = [
			'post_id'      => 0,
			'post_title'   => '',
			'images_added' => 0,
		];

		$post_table = $wpdb->prefix . 'posts';

		$postmeta_table = $wpdb->prefix . 'postmeta';

		$query = "
            SELECT     ID, post_title
            FROM       $post_table
            INNER JOIN $postmeta_table 
            ON         $post_table.ID = $postmeta_table.post_id
            WHERE      $post_table.post_type = 'post'
            AND        $post_table.post_status = 'publish'
            AND        $postmeta_table.meta_key = 'custom_images_grifus'
            AND        $postmeta_table.meta_value = 'false'
            ORDER BY   $post_table.ID ASC
        ";

		$post = $wpdb->get_row( $query );

		if ( ! is_null( $post ) && isset( $post->ID ) && isset( $post->post_title ) ) {
			$post_id = $post->ID;

			$images_added = $this->set_images( $post->ID );

			$response = [
				'post_id'      => $post->ID,
				'post_title'   => $post->post_title,
				'images_added' => $images_added,
			];
		}

		return $response;
	}
Search post not edited previously and replace images.

@return array