diff --git a/src/Plugin/Field/FieldFormatter/SoundCloudDefaultFormatter.php b/src/Plugin/Field/FieldFormatter/SoundCloudDefaultFormatter.php index aeea23c..b80c49c 100644 --- a/src/Plugin/Field/FieldFormatter/SoundCloudDefaultFormatter.php +++ b/src/Plugin/Field/FieldFormatter/SoundCloudDefaultFormatter.php @@ -10,6 +10,8 @@ namespace Drupal\soundcloudfield\Plugin\Field\FieldFormatter; use Drupal\Core\Field\FieldItemListInterface; use Drupal\Core\Field\FormatterBase; use Drupal\Core\Form\FormStateInterface; +use Drupal\Core\Url; +use Drupal\Core\Link; /** * Plugin implementation of the 'soundcloud_default' formatter. @@ -262,7 +264,9 @@ class SoundCloudDefaultFormatter extends FormatterBase { $output = html_entity_decode($final_iframe); } else { - $output = t('The SoundCloud content at !url is not available, or it is set to private.', array('!url' => l($item['url'], $item['url']))); + $soundcloud_url = Url::fromUri($item->values['url']); + $soundcloud_link = Link::fromTextAndUrl($soundcloud_url, $soundcloud_url); + $output = t('The SoundCloud content at !url is not available, or it is set to private.', array('!url' => $soundcloud_link)); } // Extract field item attributes for the theme function, and unset them