original_string: public static function formatter($view, $field)
      {
          $out = '';
          $viewModeSettings = $field->viewModeSettings;
  
          foreach ((array)$field->extra as $image) {
              if (!empty($image['file_name'])) {
                  $img = '';
                  $originalURL = normalizePath("/files/{$field->metadata->settings['upload_folder']}/{$image['file_name']}", '/');
                  $imageOptions = [];
  
                  foreach (['title', 'alt'] as $attr) {
                      if (!empty($field->metadata->settings["{$attr}_attr"]) && !empty($image[$attr])) {
                          $imageOptions[$attr] = h($image[$attr]);
                      }
                  }
  
                  if ($viewModeSettings['size']) {
                      $thumbnail = static::thumbnail(normalizePath(WWW_ROOT . "/files/{$field->metadata->settings['upload_folder']}/{$image['file_name']}"), $viewModeSettings['size']);
  
                      if ($thumbnail !== false) {
                          $thumbnail = basename($thumbnail);
                          $img = $view->Html->image(normalizePath("/files/{$field->metadata->settings['upload_folder']}/.tmb/{$thumbnail}", '/'), $imageOptions);
                      }
                  } else {
                      $img = $view->Html->image($originalURL, $imageOptions);
                  }
  
                  if ($img) {
                      switch ($viewModeSettings['link_type']) {
                          case 'content':
                              $entityURL = $field->metadata->entity->get('url');
                              if ($entityURL) {
                                  $out .= $view->Html->link($img, $entityURL, ['escape' => false]);
                              } else {
                                  $out .= $img;
                              }
                              break;
  
                          case 'file':
                              $out .= $view->Html->link($img, $originalURL, ['escape' => false, 'target' => '_blank']);
                              break;
  
                          default:
                              $out .= $img;
                              break;
                      }
                  }
              }
          }
  
          return $out;
      }
code: public static function formatter($view, $field)
      {
          $out = '';
          $viewModeSettings = $field->viewModeSettings;
  
          foreach ((array)$field->extra as $image) {
              if (!empty($image['file_name'])) {
                  $img = '';
                  $originalURL = normalizePath("/files/{$field->metadata->settings['upload_folder']}/{$image['file_name']}", '/');
                  $imageOptions = [];
  
                  foreach (['title', 'alt'] as $attr) {
                      if (!empty($field->metadata->settings["{$attr}_attr"]) && !empty($image[$attr])) {
                          $imageOptions[$attr] = h($image[$attr]);
                      }
                  }
  
                  if ($viewModeSettings['size']) {
                      $thumbnail = static::thumbnail(normalizePath(WWW_ROOT . "/files/{$field->metadata->settings['upload_folder']}/{$image['file_name']}"), $viewModeSettings['size']);
  
                      if ($thumbnail !== false) {
                          $thumbnail = basename($thumbnail);
                          $img = $view->Html->image(normalizePath("/files/{$field->metadata->settings['upload_folder']}/.tmb/{$thumbnail}", '/'), $imageOptions);
                      }
                  } else {
                      $img = $view->Html->image($originalURL, $imageOptions);
                  }
  
                  if ($img) {
                      switch ($viewModeSettings['link_type']) {
                          case 'content':
                              $entityURL = $field->metadata->entity->get('url');
                              if ($entityURL) {
                                  $out .= $view->Html->link($img, $entityURL, ['escape' => false]);
                              } else {
                                  $out .= $img;
                              }
                              break;
  
                          case 'file':
                              $out .= $view->Html->link($img, $originalURL, ['escape' => false, 'target' => '_blank']);
                              break;
  
                          default:
                              $out .= $img;
                              break;
                      }
                  }
              }
          }
  
          return $out;
      }
code_tokens: public static function formatter ( $ view , $ field ) { $ out = '' ; $ viewModeSettings = $ field -> viewModeSettings ; foreach ( ( array ) $ field -> extra as $ image ) { if ( ! empty ( $ image [ 'file_name' ] ) ) { $ img = '' ; $ originalURL = normalizePath ( "/files/{$field->metadata->settings['upload_folder']}/{$image['file_name']}" , '/' ) ; $ imageOptions = [ ] ; foreach ( [ 'title' , 'alt' ] as $ attr ) { if ( ! empty ( $ field -> metadata -> settings [ "{$attr}_attr" ] ) && ! empty ( $ image [ $ attr ] ) ) { $ imageOptions [ $ attr ] = h ( $ image [ $ attr ] ) ; } } if ( $ viewModeSettings [ 'size' ] ) { $ thumbnail = static :: thumbnail ( normalizePath ( WWW_ROOT . "/files/{$field->metadata->settings['upload_folder']}/{$image['file_name']}" ) , $ viewModeSettings [ 'size' ] ) ; if ( $ thumbnail !== false ) { $ thumbnail = basename ( $ thumbnail ) ; $ img = $ view -> Html -> image ( normalizePath ( "/files/{$field->metadata->settings['upload_folder']}/.tmb/{$thumbnail}" , '/' ) , $ imageOptions ) ; } } else { $ img = $ view -> Html -> image ( $ originalURL , $ imageOptions ) ; } if ( $ img ) { switch ( $ viewModeSettings [ 'link_type' ] ) { case 'content' : $ entityURL = $ field -> metadata -> entity -> get ( 'url' ) ; if ( $ entityURL ) { $ out .= $ view -> Html -> link ( $ img , $ entityURL , [ 'escape' => false ] ) ; } else { $ out .= $ img ; } break ; case 'file' : $ out .= $ view -> Html -> link ( $ img , $ originalURL , [ 'escape' => false , 'target' => '_blank' ] ) ; break ; default : $ out .= $ img ; break ; } } } } return $ out ; }
docstring: Renders the given field instance.
  
  When using the `Link to content` option, entities must define the "url"
  property, and it should return a valid URL for that entity.
  
  @param \Cake\View\View $view Instance of view class
  @param \Field\Model\Entity\Field $field Field instance to render
  @return string HTML
docstring_tokens: Renders the given field instance .