Add plain url feature
authorjoshuaruesweg <ruesweg@woltlab.com>
Wed, 10 Mar 2021 15:17:10 +0000 (16:17 +0100)
committerjoshuaruesweg <ruesweg@woltlab.com>
Tue, 16 Mar 2021 15:19:15 +0000 (16:19 +0100)
Display urls, which have neither an image nor a description as a simple titled link.

com.woltlab.wcf/templates/unfurlUrl.tpl
wcfsetup/install/files/lib/data/unfurl/url/UnfurlUrl.class.php

index 2d61160797c167b6ffab6236b1dcc931422d2334..02e81c7243b09400ee4b808c78c810d22ecfe80f 100644 (file)
@@ -1,18 +1,22 @@
 {if $object->status == "SUCCESSFUL"}
-       <div class="
-               unfurlUrlCard
-               {if $object->hasCoverImage()}unfurlUrlCardCoverImage{/if}
-               {if $object->hasSquaredImage()}unfurlUrlCardSquaredImage{/if}
-       ">
-               
-               <div class="unfurlUrlImage"{if !$object->getImageUrl()|empty} style="background-image: url('{$object->getImageUrl()}')"{/if}></div>
-               <div class="unfurlUrlInformation">
-                       <div class="unfurlUrlTitle">{$object->title}</div>
-                       <div class="unfurlUrlDescription">{$object->description}</div>
-                       <div class="unfurlUrlHost">{$object->getHost()}</div>
+       {if $object->isPlainUrl()}
+               <a {anchorAttributes url=$object->url isUgc=true}>{$object->title}</a>
+       {else}
+               <div class="
+                       unfurlUrlCard
+                       {if $object->hasCoverImage()}unfurlUrlCardCoverImage{/if}
+                       {if $object->hasSquaredImage()}unfurlUrlCardSquaredImage{/if}
+               ">
+
+                       <div class="unfurlUrlImage"{if !$object->getImageUrl()|empty} style="background-image: url('{$object->getImageUrl()}')"{/if}></div>
+                       <div class="unfurlUrlInformation">
+                               <div class="unfurlUrlTitle">{$object->title}</div>
+                               <div class="unfurlUrlDescription">{$object->description}</div>
+                               <div class="unfurlUrlHost">{$object->getHost()}</div>
+                       </div>
+                       <a class="unfurlUrlLinkShadow" {anchorAttributes url=$object->url appendClassname=false isUgc=true}></a>
                </div>
-               <a class="unfurlUrlLinkShadow" {anchorAttributes url=$object->url appendClassname=false isUgc=true}></a>
-       </div>
+       {/if}
 {else}
        <a {anchorAttributes url=$object->url isUgc=true}>{$object->url}</a>
 {/if}
\ No newline at end of file
index a6169d304375fa88fcf47002bbde1f01970a09ff..b06db350585f5258ac1db979feeb6e69210cb32a 100644 (file)
@@ -130,6 +130,11 @@ class UnfurlUrl extends DatabaseObject
         return $this->getImageType() === self::IMAGE_SQUARED && !empty($this->getImageUrl());
     }
 
+    public function isPlainUrl(): bool
+    {
+        return empty($this->description) && empty($this->imageID);
+    }
+
     private function getImageType(): string
     {
         if (!$this->imageID) {