You are here

protected function SoundCloudDefaultFormatter::renderEmbedCode in SoundCloud field 8

File

src/Plugin/Field/FieldFormatter/SoundCloudDefaultFormatter.php, line 284

Class

SoundCloudDefaultFormatter
Plugin implementation of the 'soundcloud_default' formatter.

Namespace

Drupal\soundcloudfield\Plugin\Field\FieldFormatter

Code

protected function renderEmbedCode($track_id, $width, $height, $autoplay) {
  return [
    '#type' => 'html_tag',
    '#tag' => 'iframe',
    '#attributes' => [
      'width' => $width,
      'height' => $height,
      'frameborder' => '0',
      'allowfullscreen' => 'allowfullscreen',
      'src' => sprintf('https://w.soundcloud.com/player/%s?autoplay=%s', $track_id, $autoplay),
    ],
  ];
}