function dynamic_background_image_selector_form in Dynamic Background 6
Same name and namespace in other branches
- 7.2 dynamic_background.module \dynamic_background_image_selector_form()
- 7 dynamic_background.module \dynamic_background_image_selector_form()
Builds image selection part of a form to be used by sub-moduels, where the user may select background images.
Parameters
int $selected_image_id:
Return value
array $form
6 calls to dynamic_background_image_selector_form()
- DynamicBackgroundReaction::options_form in modules/
dynamic_background_context/ plugins/ dynamic_background_context_reaction.inc - dynamic_background_blog_form in modules/
dynamic_background_blog/ dynamic_background_blog.module - Menu callback that generates the form used in the "My blog background" tab on the user profile page.
- dynamic_background_node_form_alter in modules/
dynamic_background_node/ dynamic_background_node.module - Hooks into the selected content types an insert a form selection option of background images uploaded by the site administrator.
- dynamic_background_panels_form_alter in modules/
dynamic_background_panels/ dynamic_background_panels.module - Implements hook_form_alter().
- dynamic_background_user_form in modules/
dynamic_background_user/ dynamic_background_user.module - Menu callback that generates the form used in the "My background" tab on the profile page.
File
- ./
dynamic_background.module, line 315 - This module enables administrators to upload images used as background on the site. The selected background image link is exposed as either $background in the page.tpl file or as /background.css.
Code
function dynamic_background_image_selector_form($selected_image_id) {
$form = array(
'#tree' => TRUE,
);
// Get all uploaded images
$images = variable_get('dynamic_background_images', array());
foreach ($images as $id => $image) {
if (!empty($image['default'])) {
// Create image thumbnail.
$picture = theme('imagecache', 'dynamic_background_thumb', $image['default'], basename($image['default']), basename($image['default']), NULL);
$form[$id]['image'] = array(
'#value' => $picture,
'#prefix' => '<div class="dynamic-background-picture">',
);
$form[$id]['selected'] = array(
'#type' => 'checkbox',
'#title' => t('Use background'),
'#default_value' => !is_null($selected_image_id) && $id == $selected_image_id ? 1 : 0,
'#suffix' => '</div>',
);
}
}
// Add some default styling to the image selector.
drupal_add_css(drupal_get_path('module', 'dynamic_background') . '/css/dynamic_background.theme.css', 'module');
drupal_add_js(drupal_get_path('module', 'dynamic_background') . '/js/dynamic_background_selector.js', 'file');
return $form;
}