Show a Unique Header Image based on Path in Drupal 7 I'm trying to customize the header with an image for each path; if not, put a default image. I found a way to do Lullabot, but it is for Drupal 6.

Is there any option for Dupal 7?

theme-settings.php

/** 
* Implementation of hook_settings() for themes. 
*/ 
function MYTHEMENAME_settings($settings) { 
    // This ensures that a 'files' directory exists if it hasn't 
    // already been been created. 
    file_check_directory(file_directory_path(), 
        FILE_CREATE_DIRECTORY, 'file_directory_path'); 
    // Check for a freshly uploaded header image, save it to the 
    // filesystem, and grab its full path for later use. 
if ($file = file_save_upload('header_image', 
    array('file_validate_is_image' =&gt; array()))) { 
$parts = pathinfo($file-&gt;filename); 
$filename = 'MYTHEMENAME_header_image.'. $parts['extension']; 
if (file_copy($file, $filename, FILE_EXISTS_REPLACE)) { 
    $settings['header_image_path'] = $file-&gt;filepath; 
    } 
} 

// Define the settings-related FormAPI elements. 
$form = array(); 
$form['header_image'] = array(
    '#type' =&gt; 'file', 
    '#title' =&gt; t('Header image'), 
    '#maxlength' =&gt; 40,
); 
$form['header_image_path'] = array( 
    '#type' =&gt; 'value', 
    '#value' =&gt; !empty($settings['header_image_path']) ? 
    $settings['header_image_path'] : '', 
); 
if (!empty($settings['header_image_path'])) { 
$form['header_image_preview'] = array( 
    '#type' =&gt; 'markup', 
    '#value' =&gt; !empty($settings['header_image_path']) ? 
        theme('image', $settings['header_image_path']) : '', 
    ); 
} 
return $form;
} 


template.php

/**
* Implementation of hook_preprocess_page().
*/
function MYTHEMENAME_preprocess_page(&amp;$variables) {
  $settings = theme_get_settings('MYTHEMENAME');
  if (!empty($settings['header_image_path'])) {
    $vars['header_image_path'] = $settings['header_image_path'];
  }
  else {
    $variables['header_image_path'] = path_to_theme().'/head.jpg';
  }
}


I tried using the Header image module but it is not working; the other option I have is to make a content type with a view and relate them to the nid.

Which option do you recommend?
If you want to define your header image in appearance settings form:

theme-settings.php

**
 * Implements hook_form_system_theme_settings_alter().
 *
 * @param $form
 *   Nested array of form elements that comprise the form.
 * @param $form_state
 *   A keyed array containing the current state of the form.
 */
function YOURTHEME_form_system_theme_settings_alter(&amp;$form, &amp;$form_state, $form_id = NULL)  {
  // Work-around for a core bug affecting admin themes. See issue #943212.
  if (isset($form_id)) {
    return;
  }

  // We are editing the $form in place, so we don't need to return anything.
  $form['YOURTHEME_settings'] = array(
    '#type' =&gt; 'fieldset',
    '#title' =&gt; t('YOUR THEME Theme Settings'),
    '#collapsible' =&gt; TRUE,
    '#collapsed' =&gt; FALSE,
  );

  // display settings
  $form['YOURTHEME_settings']['display'] = array(
    '#type' =&gt; 'fieldset',
    '#title' =&gt; 'Display options'
  );

  $form['YOURTHEME_settings']['display']['header_type'] = array(
    '#type' =&gt; 'select',
    '#title' =&gt; t('Type of header'),
    '#default_value' =&gt; theme_get_setting('header_type'),
    '#options' =&gt; array(
      'default'   =&gt; t('Default header'),
      'christmas' =&gt; t('Christmas header'),
      'easter'    =&gt; t('Easter header'),
    ),
    '#description'   =&gt; t("Select type of header"),
  );
}


template.php

/**
 * Override or insert variables into the page templates.
 */
function YOURTHEME_preprocess_page(&amp;$variables) {

  // header image   
  switch (theme_get_setting('header_type')) {
    case 'christmas' : $variables['header_image'] = path_to_theme() . '/header-christmas.jpg';
      break;
    case 'easter' : $variables['header_image'] = path_to_theme() . '/header-easter.jpg';
      break;
    default: path_to_theme() . '/header-default.jpg';
  }
}


Alternatively
You can use css to define header image paths, so instead preprocessing page variables, use template_preprocess_html to provide appropriate body classes:

/**
 * Override or insert variables into the html templates.
 */
function YOURTHEME_preprocess_html(&amp;$variables) { 
  // add holiday classes to body    
  switch (theme_get_setting('header_type')){
    case 'christmas' : $variables['classes_array'][] = 'header-christmas'; break;
    case 'easter' : $variables['classes_array'][] = 'header-easter'; break;
  }
}


css

/* HOLIDAY HEADERS */
.header-christmas #page_header { }
.header-easter #page_header { }