summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoremerham2017-06-03 02:08:53 (GMT)
committerolstjos2017-06-03 02:08:53 (GMT)
commited84c58ff93d1c0c6ef90ec865935560df1b3995 (patch)
treed50ef7ad0f9696bebccee95a4a54e3d8755c1f54
parenta051e1c158c0e8e42f83332585f4fe2d1c1e7ddc (diff)
Issue #2883529 #2883529 by emerham: Linking Issues - related to 2881204
-rw-r--r--modules/media_wysiwyg/includes/media_wysiwyg.filter.inc5
-rw-r--r--modules/media_wysiwyg/includes/media_wysiwyg.pages.inc10
-rw-r--r--modules/media_wysiwyg/js/media_wysiwyg.filter.js5
3 files changed, 14 insertions, 6 deletions
diff --git a/modules/media_wysiwyg/includes/media_wysiwyg.filter.inc b/modules/media_wysiwyg/includes/media_wysiwyg.filter.inc
index 25cee6b..1cd6a50 100644
--- a/modules/media_wysiwyg/includes/media_wysiwyg.filter.inc
+++ b/modules/media_wysiwyg/includes/media_wysiwyg.filter.inc
@@ -146,7 +146,6 @@ function media_wysiwyg_token_to_markup($match, $wysiwyg = FALSE, $langcode = NUL
}
$tag_info = drupal_json_decode($tag);
-
if (!isset($tag_info['fid'])) {
throw new Exception('No file Id');
}
@@ -216,7 +215,9 @@ function media_wysiwyg_token_to_markup($match, $wysiwyg = FALSE, $langcode = NUL
$attribute_whitelist = media_wysiwyg_allowed_attributes();
$settings['attributes'] = array_intersect_key($attributes, array_flip($attribute_whitelist));
$settings['fields'] = $fields;
-
+ if (isset($tag_info['fields']['external_url'])) {
+ $settings['fields']['external_url'] = $tag_info['fields']['external_url'];
+ }
if (!empty($tag_info['attributes']) && is_array($tag_info['attributes'])) {
$settings['attributes'] = array_intersect_key($tag_info['attributes'], array_flip($attribute_whitelist));
diff --git a/modules/media_wysiwyg/includes/media_wysiwyg.pages.inc b/modules/media_wysiwyg/includes/media_wysiwyg.pages.inc
index 41e4430..ad29167 100644
--- a/modules/media_wysiwyg/includes/media_wysiwyg.pages.inc
+++ b/modules/media_wysiwyg/includes/media_wysiwyg.pages.inc
@@ -104,12 +104,20 @@ function media_wysiwyg_format_form($form, &$form_state, $file) {
'#default_value' => $align_default,
);
}
-
// Add fields from the file, so that we can override them if necessary.
$form['options']['fields'] = array();
foreach ($fields as $field_name => $field_value) {
$file->{$field_name} = $field_value;
}
+ // 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,
+ );
field_attach_form('file', $file, $form['options']['fields'], $form_state);
$instance = field_info_instances('file', $file->type);
foreach ($instance as $field_name => $field_value) {
diff --git a/modules/media_wysiwyg/js/media_wysiwyg.filter.js b/modules/media_wysiwyg/js/media_wysiwyg.filter.js
index f3df936..ca8ba7a 100644
--- a/modules/media_wysiwyg/js/media_wysiwyg.filter.js
+++ b/modules/media_wysiwyg/js/media_wysiwyg.filter.js
@@ -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) {
+ if ((info.link_text) && (info.fields.external_url.length === 0)) {
$('a', element).html(info.link_text);
}
@@ -352,8 +352,7 @@
});
// Extract the link text, if there is any.
- file_info.link_text = (Drupal.settings.mediaDoLinkText) ? element.find('a').html() : false;
-
+ file_info.link_text = (Drupal.settings.mediaDoLinkText) ? element.find('a:not(:has(img))').html() : false;
// When a file is embedded, its fields can be overridden. To allow for
// the edge case where the same file is embedded multiple times with
// different field overrides, we look for a data-delta attribute on