Code Duplication    Length = 34-34 lines in 2 locations

projects/packages/post-images/src/class-post-images.php 1 location

@@ 899-932 (lines=34) @@
896
		 * If it does not have an ID, let `from_html` parse that content later,
897
		 * and extract an image if it has size parameters.
898
		 */
899
		if (
900
			'core/image' === $block['blockName']
901
			&& ! empty( $block['attrs']['id'] )
902
		) {
903
			$images[] = self::get_attachment_data( $block['attrs']['id'], $html_info['post_url'], $width, $height );
904
		} elseif (
905
			'core/media-text' === $block['blockName']
906
			&& ! empty( $block['attrs']['mediaId'] )
907
		) {
908
			$images[] = self::get_attachment_data( $block['attrs']['mediaId'], $html_info['post_url'], $width, $height );
909
		} elseif (
910
			/**
911
			 * Parse content from Core Gallery blocks as well from Jetpack's Tiled Gallery and Slideshow blocks.
912
			 * Gallery blocks include the ID of each one of the images in the gallery.
913
			 */
914
			in_array( $block['blockName'], array( 'core/gallery', 'jetpack/tiled-gallery', 'jetpack/slideshow' ), true )
915
			&& ! empty( $block['attrs']['ids'] )
916
		) {
917
			foreach ( $block['attrs']['ids'] as $img_id ) {
918
				$images[] = self::get_attachment_data( $img_id, $html_info['post_url'], $width, $height );
919
			}
920
		} elseif (
921
			/**
922
			 * Parse content from Jetpack's Story block.
923
			 */
924
			'jetpack/story' === $block['blockName']
925
			&& ! empty( $block['attrs']['mediaFiles'] )
926
		) {
927
			foreach ( $block['attrs']['mediaFiles'] as $media_file ) {
928
				if ( ! empty( $media_file['id'] ) ) {
929
					$images[] = self::get_attachment_data( $media_file['id'], $html_info['post_url'], $width, $height );
930
				}
931
			}
932
		}
933
934
		return $images;
935
	}

projects/plugins/jetpack/class.jetpack-post-images.php 1 location

@@ 920-953 (lines=34) @@
917
		 * If it does not have an ID, let `from_html` parse that content later,
918
		 * and extract an image if it has size parameters.
919
		 */
920
		if (
921
			'core/image' === $block['blockName']
922
			&& ! empty( $block['attrs']['id'] )
923
		) {
924
			$images[] = self::get_attachment_data( $block['attrs']['id'], $html_info['post_url'], $width, $height );
925
		} elseif (
926
			'core/media-text' === $block['blockName']
927
			&& ! empty( $block['attrs']['mediaId'] )
928
		) {
929
			$images[] = self::get_attachment_data( $block['attrs']['mediaId'], $html_info['post_url'], $width, $height );
930
		} elseif (
931
			/**
932
			 * Parse content from Core Gallery blocks as well from Jetpack's Tiled Gallery and Slideshow blocks.
933
			 * Gallery blocks include the ID of each one of the images in the gallery.
934
			 */
935
			in_array( $block['blockName'], array( 'core/gallery', 'jetpack/tiled-gallery', 'jetpack/slideshow' ), true )
936
			&& ! empty( $block['attrs']['ids'] )
937
		) {
938
			foreach ( $block['attrs']['ids'] as $img_id ) {
939
				$images[] = self::get_attachment_data( $img_id, $html_info['post_url'], $width, $height );
940
			}
941
		} elseif (
942
			/**
943
			 * Parse content from Jetpack's Story block.
944
			 */
945
			'jetpack/story' === $block['blockName']
946
			&& ! empty( $block['attrs']['mediaFiles'] )
947
		) {
948
			foreach ( $block['attrs']['mediaFiles'] as $media_file ) {
949
				if ( ! empty( $media_file['id'] ) ) {
950
					$images[] = self::get_attachment_data( $media_file['id'], $html_info['post_url'], $width, $height );
951
				}
952
			}
953
		}
954
955
		return $images;
956
	}