Commit 6687f332 authored by Gus Childs's avatar Gus Childs
Browse files

Issue #2444699: Added a loop option to the display field formatter.

parent 2ef4ca78
Loading
Loading
Loading
Loading
+3
Changes for config/schema/youtube.schema.yml: 3 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -51,6 +51,9 @@ field.formatter.settings.youtube_video:
    youtube_autoplay:
      type: boolean
      label: 'Play video automatically when loaded'
    youtube_loop:
      type: boolean
      label: 'Loop the playback of the video'
    youtube_showinfo:
      type: boolean
      label: 'Hide video title and uploader info'
+8 −1
Changes for src/Plugin/Field/FieldFormatter/YouTubeFormatter.php: 8 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -34,6 +34,7 @@ class YouTubeFormatter extends FormatterBase {
      'youtube_width' => '',
      'youtube_height' => '',
      'youtube_autoplay' => '',
      'youtube_loop' => '',
      'youtube_showinfo' => '',
      'youtube_controls' => '',
      'youtube_autohide' => '',
@@ -80,7 +81,11 @@ class YouTubeFormatter extends FormatterBase {
      '#title' => t('Play video automatically when loaded (autoplay).'),
      '#default_value' => $this->getSetting('youtube_autoplay'),
    );

    $elements['youtube_loop'] = array(
      '#type' => 'checkbox',
      '#title' => t('Loop the playback of the video (loop).'),
      '#default_value' => $this->getSetting('youtube_loop'),
    );
    $elements['youtube_showinfo'] = array(
      '#type' => 'checkbox',
      '#title' => t('Hide video title and uploader info (showinfo).'),
@@ -114,6 +119,7 @@ class YouTubeFormatter extends FormatterBase {

    $parameters = array(
      $this->getSetting('youtube_autoplay'),
      $this->getSetting('youtube_loop'),
      $this->getSetting('youtube_showinfo'),
      $this->getSetting('youtube_controls'),
      $this->getSetting('youtube_autohide'),
@@ -151,6 +157,7 @@ class YouTubeFormatter extends FormatterBase {
        '#width' => $settings['youtube_width'],
        '#height' => $settings['youtube_height'],
        '#autoplay' => $settings['youtube_autoplay'],
        '#loop' => $settings['youtube_loop'],
        '#showinfo' => $settings['youtube_showinfo'],
        '#controls' => $settings['youtube_controls'],
        '#autohide' => $settings['youtube_autohide'],
+6
Changes for youtube.module: 6 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -91,6 +91,7 @@ function youtube_theme($existing, $type, $theme, $path) {
        'width' => NULL,
        'height' => NULL,
        'autoplay' => FALSE,
        'loop' => FALSE,
        'showinfo' => FALSE,
        'controls' => FALSE,
        'autohide' => FALSE,
@@ -109,6 +110,7 @@ function theme_youtube_video($variables) {
  $width = $variables['width'];
  $height = $variables['height'];
  $autoplay = $variables['autoplay'];
  $loop = $variables['loop'];
  $showinfo = $variables['showinfo'];
  $controls = $variables['controls'];
  $autohide = $variables['autohide'];
@@ -150,6 +152,10 @@ function theme_youtube_video($variables) {
  if ($autoplay) {
    $query['autoplay'] = '1';
  }
  if ($loop) {
    $query['loop'] = '1';
    $query['playlist'] = $id;
  }
  if ($showinfo) {
    $query['showinfo'] = '0';
  }