From 680d90e1d3dea61460f86e580d9d5a73b96af77c Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Fri, 14 Jul 2023 17:35:55 +0200 Subject: [PATCH] Slightly improve the consistency of HTML generation --- .../system/bbcode/AttachmentBBCode.class.php | 44 +++++++++++-------- 1 file changed, 26 insertions(+), 18 deletions(-) diff --git a/wcfsetup/install/files/lib/system/bbcode/AttachmentBBCode.class.php b/wcfsetup/install/files/lib/system/bbcode/AttachmentBBCode.class.php index 54228c8cb4..ea111666d8 100644 --- a/wcfsetup/install/files/lib/system/bbcode/AttachmentBBCode.class.php +++ b/wcfsetup/install/files/lib/system/bbcode/AttachmentBBCode.class.php @@ -70,7 +70,7 @@ final class AttachmentBBCode extends AbstractBBCode $source = StringUtil::encodeHTML($attachment->getLink()); $title = StringUtil::encodeHTML($attachment->filename); - $image = \sprintf( + $imageElement = \sprintf( '', $source, $attachment->width, @@ -78,27 +78,35 @@ final class AttachmentBBCode extends AbstractBBCode ); if (!$hasParentLink && ($attachment->width > ATTACHMENT_THUMBNAIL_WIDTH || $attachment->height > ATTACHMENT_THUMBNAIL_HEIGHT)) { - $icon = FontAwesomeIcon::fromValues('magnifying-glass')->toHtml(24); - return << - {$image} - - {$icon} - - - HTML; + return \sprintf( + <<<'HTML' + + %s + + %s + + + HTML, + $source, + $title, + $class, + $imageElement, + FontAwesomeIcon::fromValues('magnifying-glass')->toHtml(24), + ); } return \sprintf( '%s', $title, $class, - $image, + $imageElement, ); } - $icon = FontAwesomeIcon::fromValues('magnifying-glass')->toHtml(24); - $enlarge = '' . $icon . ''; + $enlargeImageControls = \sprintf( + '%s', + FontAwesomeIcon::fromValues('magnifying-glass')->toHtml(24), + ); $linkParameters = [ 'object' => $attachment, @@ -121,7 +129,7 @@ final class AttachmentBBCode extends AbstractBBCode $imageClasses .= ' ' . $class; } - $image = \sprintf( + $imageElement = \sprintf( '', StringUtil::encodeHTML(LinkHandler::getInstance()->getLink('Attachment', $linkParameters)), $imageClasses, @@ -135,16 +143,16 @@ final class AttachmentBBCode extends AbstractBBCode StringUtil::encodeHTML(LinkHandler::getInstance()->getLink('Attachment', ['object' => $attachment])), StringUtil::encodeHTML($attachment->filename), $class, - $image, - $enlarge, + $imageElement, + $enlargeImageControls, ); } return \sprintf( '%s%s', $class, - $image, - \str_contains($imageClasses, 'embeddedAttachmentLink') ? $enlarge : '', + $imageElement, + \str_contains($imageClasses, 'embeddedAttachmentLink') ? $enlargeImageControls : '', ); } -- 2.20.1