Commit 45c2fad4 authored by emerham's avatar emerham Committed by olstjos

Issue #2884412 by emerham: add the config option for add embed link to make it optional

parent e48215d1
......@@ -112,12 +112,16 @@ function media_wysiwyg_format_form($form, &$form_state, $file) {
// Get the external url from the fid array.
$external_url = empty($query_fields['external_url']) ? NULL : $query_fields['external_url'];
// Field to attach external url's to files for linking.
$form['options']['external_url'] = array(
'#type' => 'textfield',
'#title' => t('Link Image'),
'#description' => t('Enter a URL to turn the image into a link.'),
'#default_value' => $external_url,
);
if(variable_get('media_wysiwyg_external_link', FALSE)) {
if($file->type == 'image') {
$form['options']['external_url'] = array(
'#type' => 'textfield',
'#title' => t('Link Image'),
'#description' => t('Enter a URL to turn the image into a link.'),
'#default_value' => $external_url,
);
}
}
field_attach_form('file', $file, $form['options']['fields'], $form_state);
$instance = field_info_instances('file', $file->type);
foreach ($instance as $field_name => $field_value) {
......
......@@ -300,7 +300,7 @@
// Attempt to override the link_title if the user has chosen to do this.
info.link_text = this.overrideLinkTitle(info);
// Apply link_text if present.
if ((info.link_text) && (info.fields.external_url.length === 0)) {
if ((info.link_text) && (!info.fields || !info.fields.external_url || info.fields.external_url.length === 0)) {
$('a', element).html(info.link_text);
}
......
......@@ -76,6 +76,7 @@ function media_wysiwyg_uninstall() {
variable_del('media_wysiwyg_wysiwyg_override_field_types');
variable_del('media_wysiwyg_use_link_text_for_filename');
variable_del('media_wysiwyg_alignment');
variable_del('media_wysiwyg_external_link');
}
/**
......@@ -242,3 +243,11 @@ function media_wysiwyg_update_7206() {
$message = t('If you would like to be able to align your embedded media (left, right, or center), go to /admin/config/media/browser and check "Provide alignment option when embedding media", and save the settings.');
drupal_set_message($message, 'warning', TRUE);
}
/**
* Notify upgraders that there's optional media linking functionality that needs to be enabled.
*/
function media_wysiwyg_update_7207() {
$message = t('If you would like to be able to link images to a page got o /admin/config/media/browser and check "Provide the ability to link media to pages", and save the settings.');
drupal_set_message($message, 'warning', TRUE);
}
......@@ -313,6 +313,12 @@ function media_wysiwyg_form_media_admin_config_browser_alter(&$form, &$form_stat
'#description' => t('If checked, there will be an alignment (left/right/center) option when embedding media in a WYSIWYG.'),
);
$form['wysiwyg']['media_wysiwyg_external_link'] = array(
'#type' => 'checkbox',
'#title' => t('Provide the ability to link media to pages'),
'#default_value' => variable_get('media_wysiwyg_external_link', FALSE),
'#description' => t('If checked there will be a new field when embedding that will allow users to link to the media to urls'),
);
$form['#submit'][] = 'media_wysiwyg_admin_config_browser_pre_submit';
}
......
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