From d7d084b8757ee6cad5221847cf1a50119e7a8ded Mon Sep 17 00:00:00 2001 From: Matt Wiebe Date: Fri, 17 Nov 2023 12:19:06 +0100 Subject: [PATCH] Attachments: dedupe earlier to prevent incorrect max_media --- includes/transformer/class-post.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/includes/transformer/class-post.php b/includes/transformer/class-post.php index 2117ce7..721bbec 100644 --- a/includes/transformer/class-post.php +++ b/includes/transformer/class-post.php @@ -185,7 +185,6 @@ class Post { $blocks = \parse_blocks( $this->wp_post->post_content ); $media_ids = self::get_media_ids_from_blocks( $blocks, $media_ids, $max_media ); } - $media_ids = \array_unique( $media_ids ); return \array_filter( \array_map( array( self::class, 'wp_attachment_to_activity_attachment' ), $media_ids ) ); } @@ -279,6 +278,9 @@ class Post { break; } + // depupe + $media_ids = \array_unique( $media_ids ); + // stop doing unneeded work if ( count( $media_ids ) >= $max_media ) { break;