function dynamic_background_blog_dynamic_background_css in Dynamic Background 7
Same name and namespace in other branches
- 6 modules/dynamic_background_blog/dynamic_background_blog.module \dynamic_background_blog_dynamic_background_css()
- 7.2 modules/dynamic_background_blog/dynamic_background_blog.module \dynamic_background_blog_dynamic_background_css()
Implements hook_dynamic_background_css().
File
- modules/
dynamic_background_blog/ dynamic_background_blog.module, line 156
Code
function dynamic_background_blog_dynamic_background_css($vars) {
$uid = NULL;
// There are two ways to detecte the different parts of a blog. The path
// /blog/%uid_optional of the node type blog. First we look at the node type,
// then the path.
if (isset($vars['node']) && $vars['node']->type == 'blog') {
$uid = $vars['node']->uid;
}
else {
// Try to find the uid by using path.
$parts = explode('/', drupal_get_path_alias());
if (count($parts) >= 2 && $parts[0] == DYNAMIC_BACKGROUND_BLOG_PATH && is_numeric($parts[1])) {
// Test that the 2nd part is an interger (meight be a user id).
$uid = (int) $parts[1];
}
}
// If user id was found, try to load blog background image if one is definded.
if (!is_null($uid)) {
// Get selected image id for current blog.
$image_id = dynamic_background_blog_get_image_id($uid);
if (!is_null($image_id)) {
// Get global backgrounds.
$backgrounds = variable_get('dynamic_background_images', array());
if (isset($backgrounds[$image_id]['picture'])) {
// Load image style settings.
$image_style = variable_get('dynamic_background_blog_image_style', FALSE);
return array(
'image' => $backgrounds[$image_id]['picture'],
'configuration' => variable_get('dynamic_background_blog_css', array()),
'image_style' => $image_style ? $image_style['style'] : FALSE,
);
}
}
}
}