WPCOM_JSON_API_Endpoint::is_file_supported_for_sideloading PHP Method

is_file_supported_for_sideloading() protected method

Checks that the mime type of the specified file is among those in a filterable list of mime types.
protected is_file_supported_for_sideloading ( string $file ) : boolean
$file string Path to file to get its mime type.
return boolean
    protected function is_file_supported_for_sideloading($file)
    {
        if (class_exists('finfo')) {
            // php 5.3+
            $finfo = new finfo(FILEINFO_MIME);
            $mime = explode('; ', $finfo->file($file));
            $type = $mime[0];
        } elseif (function_exists('mime_content_type')) {
            // PHP 5.2
            $type = mime_content_type($file);
        } else {
            return false;
        }
        /**
         * Filter the list of supported mime types for media sideloading.
         *
         * @since 4.0.0
         *
         * @module json-api
         *
         * @param array $supported_mime_types Array of the supported mime types for media sideloading.
         */
        $supported_mime_types = apply_filters('jetpack_supported_media_sideload_types', array('image/png', 'image/jpeg', 'image/gif', 'image/bmp', 'video/quicktime', 'video/mp4', 'video/mpeg', 'video/ogg', 'video/3gpp', 'video/3gpp2', 'video/h261', 'video/h262', 'video/h264', 'video/x-msvideo', 'video/x-ms-wmv', 'video/x-ms-asf'));
        // If the type returned was not an array as expected, then we know we don't have a match.
        if (!is_array($supported_mime_types)) {
            return false;
        }
        return in_array($type, $supported_mime_types);
    }