summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoraaron2017-09-02 02:49:55 (GMT)
committerjoseph.olstad2017-09-02 02:49:55 (GMT)
commit9e3d0da264ad4caed8dd8a5545fe26f074a8fb07 (patch)
treed5e905fe9e11fab95bfd6ff24f16b53457ba8676
parentee767e96ac937ba071ecb91ab2ee60d39f525622 (diff)
Issue #2018075 by danbohea, joseph.olstad, ParisLiakos, Anas_maw, rwohleb, emerham, abu-zakham, Frando, jrbrown, aaron: Media inline filter: Delegate "float" to outer element7.x-2.11
-rw-r--r--modules/media_wysiwyg/css/media_wysiwyg.base.css2
-rw-r--r--modules/media_wysiwyg/includes/media_wysiwyg.filter.inc14
-rw-r--r--modules/media_wysiwyg/tests/media_wysiwyg.macro.test25
3 files changed, 41 insertions, 0 deletions
diff --git a/modules/media_wysiwyg/css/media_wysiwyg.base.css b/modules/media_wysiwyg/css/media_wysiwyg.base.css
index fba97ad..33afdfa 100644
--- a/modules/media_wysiwyg/css/media_wysiwyg.base.css
+++ b/modules/media_wysiwyg/css/media_wysiwyg.base.css
@@ -11,5 +11,7 @@
margin-left: 20px;
}
.media-wysiwyg-align-center {
+ text-align: -moz-center;
+ text-align: -webkit-center;
text-align: center;
}
diff --git a/modules/media_wysiwyg/includes/media_wysiwyg.filter.inc b/modules/media_wysiwyg/includes/media_wysiwyg.filter.inc
index c9c6130..03daeae 100644
--- a/modules/media_wysiwyg/includes/media_wysiwyg.filter.inc
+++ b/modules/media_wysiwyg/includes/media_wysiwyg.filter.inc
@@ -238,6 +238,11 @@ function media_wysiwyg_token_to_markup($match, $wysiwyg = FALSE, $langcode = NUL
$settings[$dimension] = $settings['attributes'][$dimension];
}
}
+ // If the element is floated via WYSIWYG editor functionality, delegate
+ // that information to the outer element.
+ if (!empty($css_properties['float'])) {
+ $settings['float'] = $css_properties['float'];
+ }
}
foreach (array('title', 'alt') as $field_type) {
if (isset($settings['attributes'][$field_type])) {
@@ -331,6 +336,11 @@ function media_wysiwyg_token_to_markup($match, $wysiwyg = FALSE, $langcode = NUL
field_attach_prepare_view('file', array($file->fid => $file), $tag_info['view_mode'], $langcode);
entity_prepare_view('file', array($file->fid => $file), $langcode);
$element['content'] += field_attach_view('file', $file, $tag_info['view_mode'], $langcode);
+
+ // Add any float information via an extra class
+ if (!empty($settings['float'])) {
+ $element['content']['file']['#attributes']['class'][] = drupal_html_class('media-float-' . $settings['float']);
+ }
}
if (count(element_children($element['content'])) > 1) {
// Add surrounding divs to group them together.
@@ -342,6 +352,10 @@ function media_wysiwyg_token_to_markup($match, $wysiwyg = FALSE, $langcode = NUL
'media-element-container',
'media-' . $element['content']['file']['#view_mode'],
);
+ // Add the float information to the outer element.
+ if (!empty($settings['float'])) {
+ $element['content']['#attributes']['class'][] = drupal_html_class('media-float-' . $settings['float']);
+ }
if (variable_get('media_wysiwyg_remove_media_class', FALSE)) {
$classes = $element['content']['#attributes']['class'];
$element['content']['#attributes']['class'] = array_diff($classes, array('media'));
diff --git a/modules/media_wysiwyg/tests/media_wysiwyg.macro.test b/modules/media_wysiwyg/tests/media_wysiwyg.macro.test
index 7ac1bc4..82af18a 100644
--- a/modules/media_wysiwyg/tests/media_wysiwyg.macro.test
+++ b/modules/media_wysiwyg/tests/media_wysiwyg.macro.test
@@ -92,4 +92,29 @@ class MediaWYSIWYGWYSIWYGOverridesTest extends MediaWYSIWYGTestHelper {
// Ensure that the alt/title from attributes display rather the field ones.
$this->assertRaw(drupal_attributes($attributes), t('Image displays with alt/title set as attributes overriding field values.'));
}
+
+ /**
+ * Test image media overrides on images with fields attached.
+ */
+ public function testAttributeOverridesWithFields() {
+ // First make images display the title field on the preview mode we use.
+ $instance = field_read_instance('file', 'field_file_image_title_text', 'image');
+ $instance['display']['preview']['type'] = 'text_default';
+ $instance['display']['preview']['module'] = 'text';
+ field_update_instance($instance);
+
+ $files = $this->drupalGetTestFiles('image');
+ $file = file_save($files[0]);
+
+ $attributes = array(
+ 'style' => 'float: left;',
+ );
+ $fields = array(
+ 'field_file_image_title_text[und][0][value]' => $this->randomName(),
+ );
+ $nid = $this->createNode($file->fid, $attributes, $fields);
+ $this->drupalGet('node/' . $nid);
+ $this->assertRaw('float: left;', 'Image displays with overriden attributes when displays with fields.');
+ $this->assertRaw('media-float-left', 'Media float class added.');
+ }
}