Commit 4cbf035b authored by frjo's avatar frjo
Browse files

#774602: Add setting for title shortening

parent d30c1404
......@@ -238,6 +238,24 @@ function colorbox_admin_settings() {
'#collapsible' => TRUE,
'#collapsed' => TRUE
);
$form['colorbox_advanced_settings']['colorbox_title_trim'] = array(
'#type' => 'radios',
'#title' => t('Title shortening'),
'#options' => array(0 => t('Default'), 1 => t('Yes')),
'#default_value' => variable_get('colorbox_title_trim', 0),
'#description' => t('If the title should be made shorter in the Colorbox to avoid layout problems. The default is to shorten for the example styles, they need it, but not for other styles.'),
'#prefix' => '<div class="colorbox-title-trim-settings-activate">',
'#suffix' => '</div>',
);
$js_hide = variable_get('colorbox_title_trim', 0) ? '' : ' js-hide';
$form['colorbox_advanced_settings']['colorbox_title_trim_length'] = array(
'#type' => 'select',
'#title' => t('Title max length'),
'#options' => drupal_map_assoc(array(40, 45, 50, 55, 60, 70, 75, 80, 85, 90, 95, 100, 105, 110, 115, 120)),
'#default_value' => variable_get('colorbox_title_trim_length', 75),
'#prefix' => '<div class="colorbox-title-trim-settings'. $js_hide .'">',
'#suffix' => '</div>',
);
$form['colorbox_advanced_settings']['colorbox_path'] = array(
'#type' => 'textfield',
'#title' => t('Path to Colorbox'),
......
......@@ -44,10 +44,11 @@ function theme_colorbox_formatter_imagefield($element) {
}
}
// Shorten the title for the example styles when necessary.
// Shorten the title for the example styles or when title shortening is active.
$style = variable_get('colorbox_style', 'default');
if ((strpos($style, 'colorbox/example') !== FALSE) && (drupal_strlen($item['data']['title']) > 75)) {
$item['data']['title'] = drupal_substr($item['data']['title'], 0, 70) .'...';
$trim_length = variable_get('colorbox_title_trim_length', 75);
if (((strpos($style, 'colorbox/example') !== FALSE) || variable_get('colorbox_title_trim', 0)) && (drupal_strlen($item['data']['title']) > $trim_length)) {
$item['data']['title'] = drupal_substr($item['data']['title'], 0, $trim_length - 5) .'...';
}
// Build the gallery id.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment