You are here

protected function views_timelinejs_plugin_style_timelinejs::build_background in Views TimelineJS integration 7.3

Builds a timeline background from the current data row.

Return value

TimelineBackground A background object.

2 calls to views_timelinejs_plugin_style_timelinejs::build_background()
views_timelinejs_plugin_style_timelinejs::build_slide in ./views_timelinejs_plugin_style_timelinejs.inc
Builds a timeline slide from the current views data row.
views_timelinejs_plugin_style_timelinejs::build_title_slide in ./views_timelinejs_plugin_style_timelinejs.inc
Builds a timeline title slide from the current views data row.

File

./views_timelinejs_plugin_style_timelinejs.inc, line 538

Class

views_timelinejs_plugin_style_timelinejs
Style plugin to render items as TimelineJS3 slides.

Code

protected function build_background() {
  $url = '';
  if ($this->options['timeline_fields']['background']) {
    $url = $this
      ->get_field($this->view->row_index, $this->options['timeline_fields']['background']);

    // Special handling because core Image fields have no raw URL formatter.
    // Check to see if we don't have a raw URL.
    if (!filter_var($url, FILTER_VALIDATE_URL)) {

      // Attempt to extract a URL from an img or anchor tag in the string.
      $url = $this
        ->extract_url($url);
    }
  }
  $color = '';
  if ($this->options['timeline_fields']['background_color']) {
    $color = $this
      ->get_field($this->view->row_index, $this->options['timeline_fields']['background_color']);
  }
  return new TimelineBackground($url, $color);
}