From 9c7bc4edf22449eeb4749df0a316d96f3e28460b Mon Sep 17 00:00:00 2001 From: Peter Lieverdink Date: Thu, 19 Apr 2012 13:54:11 +1000 Subject: [PATCH 1/2] Do not mess with absolute background image path. --- template.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/template.php b/template.php index e9d578f..56220c4 100644 --- a/template.php +++ b/template.php @@ -78,8 +78,10 @@ function omega_d6mu_preprocess(&$vars, $hook) { */ function omega_d6mu_preprocess_page(&$vars, $hook) { ($vars['is_front']) ? $path = theme_get_setting('omega_d6mu_header_img_front_path') : $path = theme_get_setting('omega_d6mu_header_img_path'); - if (!file_exists($path)) { - // If the path to the header image is still the default as defined in omega_d6mu.info, then we need to prepend the them path. + if (!file_exists($path) && $path{0} != '/') { + // If the path to the header image is still the default as defined in + // omega_d6mu.info, or is an absolute path, then we need to prepend the + // theme path. // In any other case the path will be to a file in the files directory. $path = '/'. path_to_theme() .'/'. $path; } From 2836c99216a7a9754b64fc5840bf24a7b82f1c15 Mon Sep 17 00:00:00 2001 From: Peter Lieverdink Date: Thu, 19 Apr 2012 14:38:14 +1000 Subject: [PATCH 2/2] Add a bit of logic to cope with the ways background image filepaths can be stored :-/ --- template.php | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/template.php b/template.php index 56220c4..17f5603 100644 --- a/template.php +++ b/template.php @@ -78,15 +78,29 @@ function omega_d6mu_preprocess(&$vars, $hook) { */ function omega_d6mu_preprocess_page(&$vars, $hook) { ($vars['is_front']) ? $path = theme_get_setting('omega_d6mu_header_img_front_path') : $path = theme_get_setting('omega_d6mu_header_img_path'); - if (!file_exists($path) && $path{0} != '/') { - // If the path to the header image is still the default as defined in - // omega_d6mu.info, or is an absolute path, then we need to prepend the - // theme path. - // In any other case the path will be to a file in the files directory. - $path = '/'. path_to_theme() .'/'. $path; + if (!file_exists($path)) { + if($path{0} != '/') { + if (file_exists(getcwd() .'/'. $path)) { + // If this is simply a relative URL, for instance to a file in the + // files directory, make it absolute. + $path = '/'. $path; + } + else { + // If the path to the header image is still the default as defined in + // omega_d6mu.info, then we need to prepend the theme path. + // In any other case the path will be to a file in the files directory. + $path = '/'. path_to_theme() .'/'. $path; + } + } + else { + // Absolute URL relative to theme path... just in case? + if (file_exists(path_to_theme() . $path)) { + $path = '/'. path_to_theme() . $path; + } + } } $vars['header_img'] = 'style="background-image: url(' . $path . ');"'; - + $vars['local_footer'] = theme('omega_d6mu_local_footer'); $vars['heading_text'] = theme('omega_d6mu_heading_text'); }