Add method to set a custom image link
authorJoshua Rüsweg <josh@bastelstu.be>
Sun, 20 Jan 2019 21:50:27 +0000 (22:50 +0100)
committerJoshua Rüsweg <josh@bastelstu.be>
Sun, 20 Jan 2019 21:50:27 +0000 (22:50 +0100)
See #2825

wcfsetup/install/files/lib/system/file/upload/UploadFile.class.php

index 615e8642da574eac8be46d4c3f63a85ac891c18b..deba057abd4f910308d1561e7411fd6077a1defa 100644 (file)
@@ -1,5 +1,6 @@
 <?php
 namespace wcf\system\file\upload;
+use wcf\system\WCF;
 use wcf\util\FileUtil;
 use wcf\util\StringUtil;
 
@@ -19,6 +20,12 @@ class UploadFile {
         */
        private $location;
        
+       /**
+        * Full image link. 
+        * @var string
+        */
+       private $imageLink;
+       
        /**
         * Indicator, whether the file is already processed.
         * @var boolean 
@@ -101,7 +108,13 @@ class UploadFile {
                }
                
                if ($this->processed) {
-                       return $this->location;
+                       if ($this->imageLink === null) {
+                               // try to guess path
+                               return str_replace(WCF_DIR, WCF::getPath(), $this->location);
+                       }
+                       else {
+                               return $this->imageLink;
+                       }
                }
                else {
                        $imageData = getimagesize($this->location);
@@ -150,6 +163,15 @@ class UploadFile {
                $this->processed = true;
        }
        
+       /**
+        * Sets the new image link of the file for processed files.
+        *
+        * @param       string        $link
+        */
+       public function setImageLink($link) {
+               $this->imageLink = $link;
+       }
+       
        /**
         * Returns true, if the file is already processed. 
         *