I needed this with different images on different paths.
I created it, code looks like so:

In the admin.inc file I replaced

$form['bgs']['backstretch_image_url'] = array(
    '#title' => t('Default Image URL'),
    '#description' => t('Default URL of picture to display as backstretched background (begin with / if local to drupal). Leave blank for none.'),
    '#type' => 'textfield',
    '#default_value' => variable_get('backstretch_image_url', ''),
  );

By

$form['bgs'] = array(
    '#title' => t('backgrounds'),
    '#type' => 'fieldset',
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
  );
  $form['bgs']['backstretch_image_url'] = array(
    '#title' => t('Default Image URL'),
    '#description' => t('Default URL of picture to display as backstretched background (begin with / if local to drupal). Leave blank for none.'),
    '#type' => 'textfield',
    '#default_value' => variable_get('backstretch_image_url', ''),
  );

  $form['bgs']['backstretch_image_url_paths'] = array(
    '#title' => t('backstretch paths and their images.'),
    '#description' => t('every line is a separate entry. <br> Separate the path fro the image path with the | character.<br><front>|image1<br>node/xx|image2'),
    '#type' => 'textarea',
    '#default_value' => variable_get('backstretch_image_url_paths', ''),
  );

And in the module I altered the hook page_alter by the following code.
I am very sorry that I did not start form the latest version, you could port this.

function backstretch_page_alter(&$page) {
  $current_path = drupal_get_path_alias($_GET['q']);
  if (($library = libraries_load('backstretch')) && !empty($library['loaded'])) {
    
    if (module_exists('context')) { 
      if ($plugin = context_get_plugin('reaction', 'backstretch')) {
        $plugin->execute();
      }
    }
    $lines = explode("\n",variable_get('backstretch_image_url_paths'));
    $paths = array();
    foreach($lines as $line){
      $items = explode('|',$line);
      $paths[] = array('path' => $items[0],'image' => $items[1]);
    }
    $paths[] = array('path' => '*' , 'image' => variable_get('backstretch_image_url', ''));
    foreach($paths as $path){
      if(drupal_match_path($current_path,$path['path'])){
          $image = $path['image'];
          break;
      }
    }
      
    if ($url = $image || $plugin) {
      $settings = array(
        'backstretchURL' => $image,
        'backstretchMinWidth' => variable_get('backstretch_min_width', 0),
      );

      if (variable_get('backstretch_scroller', FALSE)) {
        $settings['backstretchScroller'] = TRUE;
        $settings['backstretchScrollerAdj'] = variable_get('backstretch_scroller_adjustment', 0);
      } 
      drupal_add_js($settings, 'setting');
      drupal_add_js(drupal_get_path('module', 'backstretch') .'/bs.js', array('scope' => 'footer'));
    } 
  } 
}

Comments

ultimateboy’s picture

Status: Active » Closed (works as designed)

This is actually nice functionality. I added context.module support with this functionality in mind.. that does allow you to create contexts throghout your site with different backgrounds. If an appropriate patch is provided, I'll look closer at adding this in, but for now, I'm going to consider this feature as working as designed given there is context.module support. Thanks!

wouters_f’s picture

Yes I chose to not use the context module in many (the simpeler) sites.
Installing it only for this module to work is a little too much.
Where available, context maks a lot of sense, but in the lighter use cases, I prefer a lighter mechanism.
I use the code above already in some sites, patch with drupal coding standards in mind will follow (still contains some notices hehe).