Code Duplication    Length = 4-7 lines in 3 locations

json-endpoints/class.wpcom-json-api-edit-media-v1-2-endpoint.php 1 location

@@ 222-228 (lines=7) @@
219
		);
220
221
		add_filter( 'jetpack_supported_media_sideload_types', $mime_type_static_filter );
222
		if (
223
			! $this->is_file_supported_for_sideloading( $tmp_filename ) &&
224
			! file_is_displayable_image( $tmp_filename )
225
		) {
226
			@unlink( $tmp_filename );
227
			return new WP_Error( 'invalid_input', 'Invalid file type.', 403 );
228
		}
229
		remove_filter( 'jetpack_supported_media_sideload_types', $mime_type_static_filter );
230
231
		// generate a new file name

_inc/lib/class.media.php 1 location

@@ 199-205 (lines=7) @@
196
		);
197
198
		add_filter( 'jetpack_supported_media_sideload_types', $mime_type_static_filter );
199
		if (
200
			! self::is_file_supported_for_sideloading( $tmp_filename ) &&
201
			! file_is_displayable_image( $tmp_filename )
202
		) {
203
			@unlink( $tmp_filename );
204
			return new WP_Error( 'invalid_input', 'Invalid file type.', 403 );
205
		}
206
		remove_filter( 'jetpack_supported_media_sideload_types', $mime_type_static_filter );
207
208
		// generate a new file name

class.json-api-endpoints.php 1 location

@@ 1938-1941 (lines=4) @@
1935
1936
		// First check to see if we get a mime-type match by file, otherwise, check to
1937
		// see if WordPress supports this file as an image. If neither, then it is not supported.
1938
		if ( ! $this->is_file_supported_for_sideloading( $tmp ) || 'image' === $type && ! file_is_displayable_image( $tmp ) ) {
1939
			@unlink( $tmp );
1940
			return new WP_Error( 'invalid_input', 'Invalid file type.', 403 );
1941
		}
1942
1943
		// emulate a $_FILES entry
1944
		$file_array = array(