Skip to content

Commit c35ddf1

Browse files
authored
Attachments: dedupe earlier to prevent incorrect max_media (#565)
1 parent 21206ec commit c35ddf1

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

includes/transformer/class-post.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,6 @@ protected function get_block_attachments( $max_media ) {
185185
$blocks = \parse_blocks( $this->wp_post->post_content );
186186
$media_ids = self::get_media_ids_from_blocks( $blocks, $media_ids, $max_media );
187187
}
188-
$media_ids = \array_unique( $media_ids );
189188

190189
return \array_filter( \array_map( array( self::class, 'wp_attachment_to_activity_attachment' ), $media_ids ) );
191190
}
@@ -279,6 +278,9 @@ protected static function get_media_ids_from_blocks( $blocks, $media_ids, $max_m
279278
break;
280279
}
281280

281+
// depupe
282+
$media_ids = \array_unique( $media_ids );
283+
282284
// stop doing unneeded work
283285
if ( count( $media_ids ) >= $max_media ) {
284286
break;

0 commit comments

Comments
 (0)