'...']). * Example: [ 123 => ['src' => 'url1'], 456 => ['src' => 'url2'] ] * The featured image ID will be added or updated automatically. * @return void */ public static function update_images_in_posts( int $post_id, array $image_ids ) { // add thumbnail information $thumb_id = get_post_thumbnail_id( $post_id ); /** * If an image is used both inside the post and as post thumbnail, the thumbnail entry overrides the regular image. */ if ( ! empty( $thumb_id ) ) { $image_ids[ $thumb_id ] = [ 'src' => wp_get_attachment_url( $thumb_id ), 'thumbnail' => true, ]; ISC_Log::log( 'thumbnail found with ID ' . $thumb_id ); } // apply filter to image array, so other developers can add their own logic $image_ids = apply_filters( 'isc_images_in_posts', $image_ids, $post_id ); if ( empty( $image_ids ) ) { $image_ids = []; } ISC_Log::log( sprintf( 'Updating %s for post %d.', self::META_KEY, $post_id ) ); self::update( $post_id, $image_ids ); } }