You are here

function dynamic_background_preprocess_page in Dynamic Background 6

Same name and namespace in other branches
  1. 7.2 dynamic_background.module \dynamic_background_preprocess_page()
  2. 7 dynamic_background.module \dynamic_background_preprocess_page()

Page preprocess function used to create the $background variable, so it can be used in page.tpl.

File

./dynamic_background.module, line 133
This module enables administrators to upload images used as background on the site. The selected background image link is exposed as either $background in the page.tpl file or as /background.css.

Code

function dynamic_background_preprocess_page(&$vars) {

  // Load image configuration.
  $images_conf = dynamic_background_load_image_configuration($vars);

  // Generate the css and add it to the site.
  if (isset($images_conf)) {
    $css = dynamic_background_create_css($images_conf);
    if ($css) {
      $vars['styles'] .= '<style type="text/css">' . $css . '</style>';
    }
    $image = array_pop($images_conf);
    $vars['background'] = 'style="background-image: url(\'' . file_create_url($image['image']) . '\')"';
  }
}