only in patch2: unchanged: --- a/modules/media_wysiwyg/media_wysiwyg.api.php +++ b/modules/media_wysiwyg/media_wysiwyg.api.php @@ -69,3 +69,23 @@ function hook_media_wysiwyg_token_to_markup_alter(&$element, $tag_info, $setting $element['#attributes']['alt'] = t('This media has been output using the @mode view mode.', array('@mode' => $tag_info['view_mode'])); } } + +/** + * Alter the dynamically built WYSIWYG Media markup. + * + * @param array $element + * The renderable array of output generated for WYSIWYG. + */ +function hook_media_wysiwyg_wysiwyg_markup_alter(&$element) { + $file = $element['#file']; + // Add an alignment class. + $langcode = field_language('file', $file, 'field_image_alignment'); + $alignment = $file->field_image_alignment[$langcode]; + $element['#item']['attributes']['class'][] = $alignment; + + // Provide the image size details. + if ($size = getimagesize($file->uri)) { + $element['#item']['width'] = $size[0]; + $element['#item']['height'] = $size[1]; + } +}