You are here

function dynamic_background_preprocess_page in Dynamic Background 7

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

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

File

./dynamic_background.module, line 155
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.
  $image_conf = dynamic_background_load_image_configuration($vars);

  // Only look at the last element (with the highest weight).
  $image_conf = array_pop($image_conf);

  // Generate the css and add it to the site.
  if (isset($image_conf)) {
    $vars['background'] = 'style="background-image: url(\'' . file_create_url($image_conf['image']) . '\')"';
  }
}