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

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

class.json-api-endpoints.php 1 location

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