From: Alexander Ebert Date: Fri, 13 Jan 2017 11:41:22 +0000 (+0100) Subject: Fixed image viewer for embedded images X-Git-Tag: 3.0.1~51 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=13416a9ddd67bb34e8146e8ee2f4fa7fe1615ae2;p=GitHub%2FWoltLab%2FWCF.git Fixed image viewer for embedded images --- diff --git a/wcfsetup/install/files/lib/system/html/output/node/HtmlOutputNodeImg.class.php b/wcfsetup/install/files/lib/system/html/output/node/HtmlOutputNodeImg.class.php index 3186ae936d..bf2392410d 100644 --- a/wcfsetup/install/files/lib/system/html/output/node/HtmlOutputNodeImg.class.php +++ b/wcfsetup/install/files/lib/system/html/output/node/HtmlOutputNodeImg.class.php @@ -52,51 +52,58 @@ class HtmlOutputNodeImg extends AbstractHtmlOutputNode { else $element->removeAttribute('srcset'); } } - else if (MODULE_IMAGE_PROXY) { + else { $src = $element->getAttribute('src'); if (!$src) { DOMUtil::removeNode($element); continue; } - $urlComponents = parse_url($src); - if ($urlComponents === false) { - // not a valid URL, discard it - DOMUtil::removeNode($element); - continue; - } - - if (empty($urlComponents['host'])) { - // relative URL, ignore it - continue; - } - - $element->setAttribute('data-valid', 'true'); - - if (!empty($urlComponents['path']) && preg_match('~\.svg~', basename($urlComponents['path']))) { - // we can't proxy SVG, ignore it - continue; - } - - $element->setAttribute('src', $this->getProxyLink($src)); + $class = $element->getAttribute('class'); + if ($class) $class .= ' '; + $class .= 'jsResizeImage'; + $element->setAttribute('class', $class); - $srcset = $element->getAttribute('srcset'); - if ($srcset) { - // simplified regex to check if it appears to be a valid list of sources - if (!preg_match('~^[^\s]+\s+[0-9\.]+[wx](,\s*[^\s]+\s+[0-9\.]+[wx])*~', $srcset)) { - $element->removeAttribute('srcset'); + if (MODULE_IMAGE_PROXY) { + $urlComponents = parse_url($src); + if ($urlComponents === false) { + // not a valid URL, discard it + DOMUtil::removeNode($element); continue; } - $sources = explode(',', $srcset); - $srcset = ''; - foreach ($sources as $source) { - $tmp = preg_split('~\s+~', StringUtil::trim($source)); - if (!empty($srcset)) $srcset .= ', '; - $srcset .= $this->getProxyLink($tmp[0]) . ' ' . $tmp[1]; + if (empty($urlComponents['host'])) { + // relative URL, ignore it + continue; } - $element->setAttribute('srcset', $srcset); + $element->setAttribute('data-valid', 'true'); + + if (!empty($urlComponents['path']) && preg_match('~\.svg~', basename($urlComponents['path']))) { + // we can't proxy SVG, ignore it + continue; + } + + $element->setAttribute('src', $this->getProxyLink($src)); + + $srcset = $element->getAttribute('srcset'); + if ($srcset) { + // simplified regex to check if it appears to be a valid list of sources + if (!preg_match('~^[^\s]+\s+[0-9\.]+[wx](,\s*[^\s]+\s+[0-9\.]+[wx])*~', $srcset)) { + $element->removeAttribute('srcset'); + continue; + } + + $sources = explode(',', $srcset); + $srcset = ''; + foreach ($sources as $source) { + $tmp = preg_split('~\s+~', StringUtil::trim($source)); + if (!empty($srcset)) $srcset .= ', '; + $srcset .= $this->getProxyLink($tmp[0]) . ' ' . $tmp[1]; + } + + $element->setAttribute('srcset', $srcset); + } } } } diff --git a/wcfsetup/install/files/style/ui/attachment.scss b/wcfsetup/install/files/style/ui/attachment.scss index ec0d7afdc3..3d8bee9482 100644 --- a/wcfsetup/install/files/style/ui/attachment.scss +++ b/wcfsetup/install/files/style/ui/attachment.scss @@ -180,7 +180,8 @@ } /* embedded images */ -.embeddedAttachmentLink { +.embeddedAttachmentLink, +.embeddedImageLink { border: 1px solid $wcfContentBorderInner; display: inline-block; max-width: 100%;