You are here

function dynamic_background_node_dynamic_background_css in Dynamic Background 6

Same name and namespace in other branches
  1. 7.2 modules/dynamic_background_node/dynamic_background_node.module \dynamic_background_node_dynamic_background_css()
  2. 7 modules/dynamic_background_node/dynamic_background_node.module \dynamic_background_node_dynamic_background_css()

Implements hook_dynamic_background_css().

File

modules/dynamic_background_node/dynamic_background_node.module, line 174
This module provides the node adminitrators with the option to use different dynamic background images for each node.

Code

function dynamic_background_node_dynamic_background_css($vars) {

  // Find the selected image id.
  $image_id = NULL;
  if (isset($vars['node']) && isset($vars['node']->dynamic_background)) {
    $node = $vars['node'];
    $image_id = NULL;
    foreach ($node->dynamic_background as $id => $value) {
      if ($value['selected']) {
        $image_id = $id;
        break;
      }
    }

    // Load imagecache settings.
    $imagecache = variable_get('dynamic_background_node_imagecache', FALSE);

    // Generate the css based in the image id.
    if (!is_null($image_id)) {
      $backgrounds = variable_get('dynamic_background_images', array());
      if (isset($backgrounds[$image_id])) {
        return array(
          'image' => $backgrounds[$image_id]['default'],
          'configuration' => variable_get('dynamic_background_node_css', array()),
          'imagecache' => $imagecache ? $imagecache['present'] : FALSE,
          'weight' => 210,
        );
      }
    }
  }
}