original_string: public function thumbnail($name)
      {
          $this->loadModel('Field.FieldInstances');
          $instance = $this->_getInstance($name);
  
          if (!$instance) {
              throw new NotFoundException(__d('field', 'Invalid field instance.'), 400);
          }
  
          if (empty($this->request->query['file'])) {
              throw new NotFoundException(__d('field', 'Invalid file name.'), 400);
          }
  
          if (empty($this->request->query['size'])) {
              throw new NotFoundException(__d('field', 'Invalid image size.'), 400);
          }
  
          $imagePath = normalizePath(WWW_ROOT . "/files/{$instance->settings['upload_folder']}/{$this->request->query['file']}");
          $tmb = ImageToolbox::thumbnail($imagePath, $this->request->query['size']);
  
          if ($tmb !== false) {
              $this->response->file($tmb);
  
              return $this->response;
          }
  
          throw new NotFoundException(__d('field', 'Thumbnail could not be found, check write permissions?'), 500);
      }
code: public function thumbnail($name)
      {
          $this->loadModel('Field.FieldInstances');
          $instance = $this->_getInstance($name);
  
          if (!$instance) {
              throw new NotFoundException(__d('field', 'Invalid field instance.'), 400);
          }
  
          if (empty($this->request->query['file'])) {
              throw new NotFoundException(__d('field', 'Invalid file name.'), 400);
          }
  
          if (empty($this->request->query['size'])) {
              throw new NotFoundException(__d('field', 'Invalid image size.'), 400);
          }
  
          $imagePath = normalizePath(WWW_ROOT . "/files/{$instance->settings['upload_folder']}/{$this->request->query['file']}");
          $tmb = ImageToolbox::thumbnail($imagePath, $this->request->query['size']);
  
          if ($tmb !== false) {
              $this->response->file($tmb);
  
              return $this->response;
          }
  
          throw new NotFoundException(__d('field', 'Thumbnail could not be found, check write permissions?'), 500);
      }
code_tokens: public function thumbnail ( $ name ) { $ this -> loadModel ( 'Field.FieldInstances' ) ; $ instance = $ this -> _getInstance ( $ name ) ; if ( ! $ instance ) { throw new NotFoundException ( __d ( 'field' , 'Invalid field instance.' ) , 400 ) ; } if ( empty ( $ this -> request -> query [ 'file' ] ) ) { throw new NotFoundException ( __d ( 'field' , 'Invalid file name.' ) , 400 ) ; } if ( empty ( $ this -> request -> query [ 'size' ] ) ) { throw new NotFoundException ( __d ( 'field' , 'Invalid image size.' ) , 400 ) ; } $ imagePath = normalizePath ( WWW_ROOT . "/files/{$instance->settings['upload_folder']}/{$this->request->query['file']}" ) ; $ tmb = ImageToolbox :: thumbnail ( $ imagePath , $ this -> request -> query [ 'size' ] ) ; if ( $ tmb !== false ) { $ this -> response -> file ( $ tmb ) ; return $ this -> response ; } throw new NotFoundException ( __d ( 'field' , 'Thumbnail could not be found, check write permissions?' ) , 500 ) ; }
docstring: Returns an scaled version of the given file image.
  
  The following GET variables must be set on request:
  
  - file: The image's file name to scale.
  - size: A preview size name, sett `ImageToolbox::getPreviews()`
  
  If any of these variables is not present an exception will be throw.
  
  @param string $name EAV attribute name
  @return \Cake\Network\Response
  @throws \Cake\Network\Exception\NotFoundException When field instance
  is not found.
docstring_tokens: Returns an scaled version of the given file image .