Code Duplication    Length = 4-7 lines in 3 locations

_inc/lib/class.media.php 1 location

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

class.json-api-endpoints.php 1 location

@@ 1876-1879 (lines=4) @@
1873
1874
		// First check to see if we get a mime-type match by file, otherwise, check to
1875
		// see if WordPress supports this file as an image. If neither, then it is not supported.
1876
		if ( ! $this->is_file_supported_for_sideloading( $tmp ) || 'image' === $type && ! file_is_displayable_image( $tmp ) ) {
1877
			@unlink( $tmp );
1878
			return new WP_Error( 'invalid_input', 'Invalid file type.', 403 );
1879
		}
1880
1881
		// emulate a $_FILES entry
1882
		$file_array = array(

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