You are here

function DynamicBackgroundReaction::execute in Dynamic Background 7.2

Same name and namespace in other branches
  1. 6 modules/dynamic_background_context/plugins/dynamic_background_context_reaction.inc \DynamicBackgroundReaction::execute()
  2. 7 modules/dynamic_background_context/plugins/dynamic_background_context_reaction.inc \DynamicBackgroundReaction::execute()

Find the selected image and return its id.

File

modules/dynamic_background_context/plugins/dynamic_background_context_reaction.inc, line 52
Implements a new context reaction that can be used to set dynamic background images based on context.

Class

DynamicBackgroundReaction
@file Implements a new context reaction that can be used to set dynamic background images based on context.

Code

function execute() {
  $image = FALSE;
  foreach ($this
    ->get_contexts() as $context) {
    if (isset($context->reactions['dynamic_background'])) {
      $image = dynamic_background_active_image('context', $context->name);

      // If no image have been found try to select random image
      // (if configured).
      $image_behaviour = variable_get('dynamic_background_context_image_behaviour', array());
      if (!$image && (isset($image_behaviour['random']) && $image_behaviour['random'])) {
        $image = dynamic_background_random_image('context', $context->name);
      }
      break;
    }
  }
  return $image;
}