Loading src/Plugin/Field/FieldFormatter/TrackDaFilesFormatter.php +10 −9 Original line number Diff line number Diff line Loading @@ -39,6 +39,7 @@ class TrackDaFilesFormatter extends FileFormatterBase { $url = track_da_files_create_url($file->getFileUri()); $options['attributes']['type'] = $mime_type . '; length=' . $filesize; $options['query']['file'] = '1'; $item = $file->_referringItem; if (isset($type)) { $options['query']['type'] = $type; Loading @@ -48,7 +49,7 @@ class TrackDaFilesFormatter extends FileFormatterBase { $options['query']['id'] = $id; } $text = isset($file->description) ? $file->description : $filename; $text = isset($item->description) ? $item->description : $filename; $link = \Drupal::l($text, Url::fromUri($url, $options)); $elements[$delta] = array( Loading @@ -61,12 +62,12 @@ class TrackDaFilesFormatter extends FileFormatterBase { ); // Pass field item attributes to the theme function. if (isset($file->_attributes)) { if (isset($item->_attributes)) { $elements[$delta] += array('#attributes' => array()); $elements[$delta]['#attributes'] += $file->_attributes; $elements[$delta]['#attributes'] += $item->_attributes; // Unset field item attributes since they have been included in the // formatter output and should not be rendered in the field template. unset($file->_attributes); unset($item->_attributes); } } if (!empty($elements)) { Loading Loading
src/Plugin/Field/FieldFormatter/TrackDaFilesFormatter.php +10 −9 Original line number Diff line number Diff line Loading @@ -39,6 +39,7 @@ class TrackDaFilesFormatter extends FileFormatterBase { $url = track_da_files_create_url($file->getFileUri()); $options['attributes']['type'] = $mime_type . '; length=' . $filesize; $options['query']['file'] = '1'; $item = $file->_referringItem; if (isset($type)) { $options['query']['type'] = $type; Loading @@ -48,7 +49,7 @@ class TrackDaFilesFormatter extends FileFormatterBase { $options['query']['id'] = $id; } $text = isset($file->description) ? $file->description : $filename; $text = isset($item->description) ? $item->description : $filename; $link = \Drupal::l($text, Url::fromUri($url, $options)); $elements[$delta] = array( Loading @@ -61,12 +62,12 @@ class TrackDaFilesFormatter extends FileFormatterBase { ); // Pass field item attributes to the theme function. if (isset($file->_attributes)) { if (isset($item->_attributes)) { $elements[$delta] += array('#attributes' => array()); $elements[$delta]['#attributes'] += $file->_attributes; $elements[$delta]['#attributes'] += $item->_attributes; // Unset field item attributes since they have been included in the // formatter output and should not be rendered in the field template. unset($file->_attributes); unset($item->_attributes); } } if (!empty($elements)) { Loading