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

@@ 153-159 (lines=7) @@
150
		);
151
152
		add_filter( 'jetpack_supported_media_sideload_types', $mime_type_static_filter );
153
		if (
154
			! self::is_file_supported_for_sideloading( $tmp_filename ) &&
155
			! file_is_displayable_image( $tmp_filename )
156
		) {
157
			@unlink( $tmp_filename );
158
			return new WP_Error( 'invalid_input', 'Invalid file type.', 403 );
159
		}
160
		remove_filter( 'jetpack_supported_media_sideload_types', $mime_type_static_filter );
161
162
		// generate a new file name

class.json-api-endpoints.php 1 location

@@ 1923-1926 (lines=4) @@
1920
1921
		// First check to see if we get a mime-type match by file, otherwise, check to
1922
		// see if WordPress supports this file as an image. If neither, then it is not supported.
1923
		if ( ! $this->is_file_supported_for_sideloading( $tmp ) || 'image' === $type && ! file_is_displayable_image( $tmp ) ) {
1924
			@unlink( $tmp );
1925
			return new WP_Error( 'invalid_input', 'Invalid file type.', 403 );
1926
		}
1927
1928
		// emulate a $_FILES entry
1929
		$file_array = array(