From b71825e6e44d9f79a424826d5b21322e7659d705 Mon Sep 17 00:00:00 2001 From: Matthias Schmidt Date: Fri, 13 Feb 2015 20:58:53 +0100 Subject: [PATCH] Add messageFloatObject(Left|Right) CSS classes --- .../system/bbcode/AttachmentBBCode.class.php | 31 ++++++++++--------- wcfsetup/install/files/style/message.less | 12 ++++++- 2 files changed, 28 insertions(+), 15 deletions(-) diff --git a/wcfsetup/install/files/lib/system/bbcode/AttachmentBBCode.class.php b/wcfsetup/install/files/lib/system/bbcode/AttachmentBBCode.class.php index 191f14fc3c..2323cc2840 100644 --- a/wcfsetup/install/files/lib/system/bbcode/AttachmentBBCode.class.php +++ b/wcfsetup/install/files/lib/system/bbcode/AttachmentBBCode.class.php @@ -75,18 +75,15 @@ class AttachmentBBCode extends AbstractBBCode { $result = ''; if ($width > 0) { - $style = ''; - if ($alignment == 'left') { - $style .= 'float: left; margin: 0 15px 7px 0'; - } - else if ($alignment == 'right') { - $style .= 'float: right; margin: 0 0 7px 15px'; + $class = ''; + if ($alignment == 'left' || $alignment == 'right') { + $class = 'messageFloatObject'.ucfirst($alignment); } $source = StringUtil::encodeHTML(LinkHandler::getInstance()->getLink('Attachment', array('object' => $attachment))); $title = StringUtil::encodeHTML($attachment->filename); - $result = ''; + $result = ''; } else { $linkParameters = array( @@ -94,17 +91,23 @@ class AttachmentBBCode extends AbstractBBCode { ); if ($attachment->hasThumbnail()) $linkParameters['thumbnail'] = 1; - $style = ''; - if ($alignment == 'left') { - $style .= 'float: left; margin: 0 15px 7px 0'; + $class = ''; + if ($alignment == 'left' || $alignment == 'right') { + $class = 'messageFloatObject'.ucfirst($alignment); + } + + $imageClasses = ''; + if (!$attachment->hasThumbnail()) { + $imageClasses = 'embeddedAttachmentLink jsResizeImage'; } - else if ($alignment == 'right') { - $style .= 'float: right; margin: 0 0 7px 15px'; + + if ($class && (!$attachment->hasThumbnail() || !$attachment->canDownload())) { + $imageClasses .= ' '.$class; } - $result = 'hasThumbnail() ? ' class="embeddedAttachmentLink jsResizeImage"' : '').' style="width: '.($attachment->hasThumbnail() ? $attachment->thumbnailWidth : $attachment->width).'px; height: '.($attachment->hasThumbnail() ? $attachment->thumbnailHeight: $attachment->height).'px;' . ((!$attachment->hasThumbnail() || !$attachment->canDownload()) ? $style : '').'" alt="" />'; + $result = ''; if ($attachment->hasThumbnail() && $attachment->canDownload()) { - $result = ''.$result.''; + $result = ''.$result.''; } } diff --git a/wcfsetup/install/files/style/message.less b/wcfsetup/install/files/style/message.less index 2c687bf1a7..6c3f33d505 100644 --- a/wcfsetup/install/files/style/message.less +++ b/wcfsetup/install/files/style/message.less @@ -1106,4 +1106,14 @@ li:nth-child(2n+1) .message { display: none; } } -} \ No newline at end of file +} + +.messageFloatObjectLeft { + float: left; + margin: 0 @wcfGapMedium @wcfGapSmall 0; +} + +.messageFloatObjectRight { + float: right; + margin: 0 0 @wcfGapSmall @wcfGapMedium; +} -- 2.20.1