original_string: public static function fromUploadedFile(FormFlashFile $uploadedFile, array $params = [])
      {
          $parts = pathinfo($uploadedFile->getClientFilename());
          $filename = $parts['basename'];
          $ext = $parts['extension'];
          $basename = $parts['filename'];
          $file = $uploadedFile->getTmpFile();
          $path = dirname($file);
  
          $config = Grav::instance()['config'];
  
          $media_params = $config->get('media.types.' . strtolower($ext));
          if (!\is_array($media_params)) {
              return null;
          }
  
          $params += $media_params;
  
          // Add default settings for undefined variables.
          $params += (array)$config->get('media.types.defaults');
          $params += [
              'type' => 'file',
              'thumb' => 'media/thumb.png',
              'mime' => 'application/octet-stream',
              'filepath' => $file,
              'filename' => $filename,
              'basename' => $basename,
              'extension' => $ext,
              'path' => $path,
              'modified' => filemtime($file),
              'thumbnails' => []
          ];
  
          $locator = Grav::instance()['locator'];
  
          $file = $locator->findResource("image://{$params['thumb']}");
          if ($file) {
              $params['thumbnails']['default'] = $file;
          }
  
          return static::fromArray($params);
      }
code: public static function fromUploadedFile(FormFlashFile $uploadedFile, array $params = [])
      {
          $parts = pathinfo($uploadedFile->getClientFilename());
          $filename = $parts['basename'];
          $ext = $parts['extension'];
          $basename = $parts['filename'];
          $file = $uploadedFile->getTmpFile();
          $path = dirname($file);
  
          $config = Grav::instance()['config'];
  
          $media_params = $config->get('media.types.' . strtolower($ext));
          if (!\is_array($media_params)) {
              return null;
          }
  
          $params += $media_params;
  
          // Add default settings for undefined variables.
          $params += (array)$config->get('media.types.defaults');
          $params += [
              'type' => 'file',
              'thumb' => 'media/thumb.png',
              'mime' => 'application/octet-stream',
              'filepath' => $file,
              'filename' => $filename,
              'basename' => $basename,
              'extension' => $ext,
              'path' => $path,
              'modified' => filemtime($file),
              'thumbnails' => []
          ];
  
          $locator = Grav::instance()['locator'];
  
          $file = $locator->findResource("image://{$params['thumb']}");
          if ($file) {
              $params['thumbnails']['default'] = $file;
          }
  
          return static::fromArray($params);
      }
code_tokens: public static function fromUploadedFile ( FormFlashFile $ uploadedFile , array $ params = [ ] ) { $ parts = pathinfo ( $ uploadedFile -> getClientFilename ( ) ) ; $ filename = $ parts [ 'basename' ] ; $ ext = $ parts [ 'extension' ] ; $ basename = $ parts [ 'filename' ] ; $ file = $ uploadedFile -> getTmpFile ( ) ; $ path = dirname ( $ file ) ; $ config = Grav :: instance ( ) [ 'config' ] ; $ media_params = $ config -> get ( 'media.types.' . strtolower ( $ ext ) ) ; if ( ! \ is_array ( $ media_params ) ) { return null ; } $ params += $ media_params ; // Add default settings for undefined variables. $ params += ( array ) $ config -> get ( 'media.types.defaults' ) ; $ params += [ 'type' => 'file' , 'thumb' => 'media/thumb.png' , 'mime' => 'application/octet-stream' , 'filepath' => $ file , 'filename' => $ filename , 'basename' => $ basename , 'extension' => $ ext , 'path' => $ path , 'modified' => filemtime ( $ file ) , 'thumbnails' => [ ] ] ; $ locator = Grav :: instance ( ) [ 'locator' ] ; $ file = $ locator -> findResource ( "image://{$params['thumb']}" ) ; if ( $ file ) { $ params [ 'thumbnails' ] [ 'default' ] = $ file ; } return static :: fromArray ( $ params ) ; }
docstring: Create Medium from an uploaded file
  
  @param  FormFlashFile $uploadedFile
  @param  array  $params
  @return Medium
docstring_tokens: Create Medium from an uploaded file