Commit 9e3d0da2 authored by aaron's avatar aaron Committed by joseph.olstad

Issue #2018075 by danbohea, joseph.olstad, ParisLiakos, Anas_maw, rwohleb,...

Issue #2018075 by danbohea, joseph.olstad, ParisLiakos, Anas_maw, rwohleb, emerham, abu-zakham, Frando, jrbrown, aaron: Media inline filter: Delegate "float" to outer element
parent ee767e96
......@@ -11,5 +11,7 @@
margin-left: 20px;
}
.media-wysiwyg-align-center {
text-align: -moz-center;
text-align: -webkit-center;
text-align: center;
}
......@@ -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'));
......
......@@ -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.');
}
}
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