Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cope with various filepaths as theme header background. #3

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 20 additions & 4 deletions template.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,28 @@ 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.
// In any other case the path will be to a file in the files directory.
$path = '/'. path_to_theme() .'/'. $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');
}
Expand Down