function fancybox_init in fancyBox 7.2
Same name and namespace in other branches
- 6 fancybox.module \fancybox_init()
- 7 fancybox.module \fancybox_init()
Implements hook_init().
File
- ./
fancybox.module, line 33 - Provides the fancyBox jQuery plugin, a tool that offers a nice and elegant way to add zooming functionality for images, html content and multi-media on your webpages, and an extensive settings page for configuring fancyBox settings and how fancyBox…
Code
function fancybox_init() {
if (fancybox_active()) {
$library = libraries_detect('fancybox');
if ($library['installed']) {
libraries_load_files($library);
$settings = _fancybox_filter_settings(variable_get('fancybox_settings'));
$context = array(
'alterable' => &$settings,
);
drupal_alter('fancybox_settings', $settings['options'], $settings['helpers'], $context);
if (isset($settings['options']['padding']) && !is_numeric($settings['options']['padding'])) {
$settings['options']['padding'] = json_decode($settings['options']['padding']);
}
if (isset($settings['options']['margin']) && !is_numeric($settings['options']['margin'])) {
$settings['options']['margin'] = json_decode($settings['options']['margin']);
}
if (isset($settings['helpers']['title_enabled']) && $settings['helpers']['title_enabled'] == 0) {
$settings['helpers']['title'] = NULL;
}
if (isset($settings['helpers']['overlay_enabled']) && $settings['helpers']['overlay_enabled'] == 0) {
$settings['helpers']['overlay'] = NULL;
}
if (empty($settings['options'])) {
unset($settings['options']);
}
if (empty($settings['helpers'])) {
unset($settings['helpers']);
}
drupal_add_js(array(
'fancybox' => $settings,
), 'setting');
}
else {
watchdog('fancybox', $library['error message'], NULL, WATCHDOG_ERROR);
}
}
}