Support » Plugin: Auto Upload Images » Improvement of URL matching

  • Resolved Malaiac

    (@malaiac)


    So I got multiple errors from ImageUploader::getFilename()

    Some URL, like
    https://lh3.googleusercontent.com/nFZVza6phshhw7VJ7-h2WP5Rrw1ASB1RV27pCDNXQYoIqmK-3pfL7BMCuQZ8mqfYf32ywCebbZdrtGCPHMOX6r1ZGy-_yPzcUkzykwYRqwA09cwLRfoxDJmaprQJyK6IUgWuYwuM
    do not work with the function

    I propose an improvement :

    
        /**
         * Return custom image name with user rules
         * @return string Custom file name
         */
        public function getFilename()
        {
            $filename = basename($this->url);
            if(preg_match('/(.*)?(\.+[^.]*)$/', $filename, $name_parts)) {
                $this->filename = $name_parts[1];
                $postfix = $name_parts[2];
    
                if (preg_match('/^(\.[^?]*)\?.*/i', $postfix, $postfix_extra)) {
                    $postfix = $postfix_extra[1];
                }
    
            }
            else {
                $this->filename = $filename;
                $postfix = '';
            }
           
    
            $filename = $this->resolvePattern(WpAutoUpload::getOption('image_name'));
            return $filename . $postfix;
        }
    
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.