Fix centering image of image viewer
authorCyperghost <olaf_schmitz_1@t-online.de>
Wed, 13 Dec 2023 12:06:04 +0000 (13:06 +0100)
committerCyperghost <olaf_schmitz_1@t-online.de>
Wed, 13 Dec 2023 12:06:04 +0000 (13:06 +0100)
wcfsetup/install/files/lib/system/bbcode/AttachmentBBCode.class.php

index 8cad546ee60b1c6ec1813a3be7d0c39e79b208c7..b2341d0db930d9f6a9ea0aad63db69f1f388a098 100644 (file)
@@ -91,7 +91,7 @@ final class AttachmentBBCode extends AbstractBBCode
         );
 
         if (!$hasParentLink && ($attachment->width > ATTACHMENT_THUMBNAIL_WIDTH || $attachment->height > ATTACHMENT_THUMBNAIL_HEIGHT)) {
-            return \sprintf(
+            $result = \sprintf(
                 <<<'HTML'
                     <a href="%s" title="%s" class="embeddedAttachmentLink jsImageViewer %s" style="width: %s">
                         %s
@@ -107,23 +107,22 @@ final class AttachmentBBCode extends AbstractBBCode
                 $imageElement,
                 FontAwesomeIcon::fromValues('magnifying-glass')->toHtml(24),
             );
+        } else {
+            $result = \sprintf(
+                '<span title="%s" class="%s" style="width: %s">%s</span>',
+                $title,
+                $class,
+                $width,
+                $imageElement,
+            );
         }
-
-        $span = \sprintf(
-            '<span title="%s" class="%s" style="width: %s">%s</span>',
-            $title,
-            $class,
-            $width,
-            $imageElement,
-        );
-
         if ($alignment === 'center') {
             return \sprintf(
                 '<p class="text-center">%s</p>',
-                $span,
+                $result,
             );
         }
-        return $span;
+        return $result;
     }
 
     private function showImageAsThumbnail(Attachment $attachment, string $alignment, bool $hasParentLink, string $width): string