Get the short URL of an image (with optional transformations)

@param Http\ImageUrl $imageUrl An instance of an imageUrl
@param boolean $asString Set to true to return the URL as a string
@return GuzzleUrl|string
@throws InvalidArgumentException
180222
public function getShortUrl(Http\ImageUrl $imageUrl, $asString = false) {
        try {
            // Generate the short URL to fetch the ID
            $response = $this->generateShortUrl($imageUrl);

            $shortUrl = sprintf(
                $this->getBaseUrl() . '/s/%s',
                $response['id']
            );

            if (!$asString) {
                $shortUrl = GuzzleUrl::factory($shortUrl);
            }
        } catch (GuzzleException $e) {
            throw new InvalidArgumentException('Could not generate short URL', 0, $e);
        }

        return $shortUrl;
    }
1078329
public function fullUrl($url = false, $omitProtocol = false, $omitBaseUrl = false) {
        if (!$url) {
            $url = $this->view->url();
        }
        $fullUrl = new Garp_Util_FullUrl($url, $omitProtocol, $omitBaseUrl);
        return $fullUrl->__toString();
    }
1025783
public function addImageUrl($imageUrl)
    {
        if (!in_array($imageUrl, $this->imageUrls)) {
            array_push($this->imageUrls, $imageUrl);
        }
        return $this;
    }
275431
public function validateUrl($url)
    {
        if ('' === $url) {
            return $this;
        }

        if (!is_string($url) || strlen($url) > 2000) {
            throw new InvalidArgumentException(
                'URL must be a string of at most 2,000 characters',
                400
            );
        }

        return $this;
    }
1360313
function getAttributes($asString = false)
    {
        if ($asString) {
            return $this->_getAttrString($this->_attributes);
        } else {
            return $this->_attributes;
        }
    }
652817
protected function getImageUrl()
    {
        $imageUrl = "";

        if ($this->getImagePath()) {
            $imageUrl = $this->getImageDirUrl() . $this->getImageName();
        }

        return $imageUrl;
    }
690660
protected function getResizedImageUrl()
    {
        $imageUrl = "";

        if ($this->getResizedImagePath()) {
            $imageUrl = $this->getImageDirUrl() . $this->getResizedImageName();
        }

        return $imageUrl;
    }
402044
public function viewImage(ImageInterface $imageMedia, $absoluteUrl = false)
    {
        $this->prepareRouterContext();

        $routeReferenceType = $this->getReferenceType($absoluteUrl);

        $generatedRoute = $this
            ->router
            ->generate($this->imageViewControllerRouteName, [
                'id' => (int) $imageMedia->getId(),
                '_format' => $imageMedia->getExtension(),
            ], $routeReferenceType);

        $this->fixRouterContext();

        return $generatedRoute;
    }
541327
public function setImageUrl($imageUrl)
    {
        $this->style    = null;
        $this->subStyle = null;
        $this->imageUrl = (string)$imageUrl;
        return $this;
    }
999475
public function image($url, $alt = null, $attributes = [], $secure = null)
    {
        $attributes['alt'] = $alt;

        return $this->toHtmlString('<img src="' . $this->url->asset($url,
            $secure) . '"' . $this->attributes($attributes) . '>');
    }
1138060
private function getRequest($url)
    {
        if ($this->baseUri && substr($url, 0, 1) != '/') {
            throw new \InvalidArgumentException(
                sprintf("Invalid uri '%s' with baseUri '%s'", $url, $this->baseUri->get(false))
            );
        }

        if ($this->baseUri && $url) {
            $uri = clone $this->baseUri;
            $uri->setPath($uri->getPath() . $url);
        } else {
            $uri = $url instanceof Uri ? $url : new Uri($url);
        }

        return new Request($uri);
    }
151078
public function getImageUrl()
    {
        return !$this->hasImage() ?
            $this->getImageDefaultUrl() :
            $this->_imageUrl($this->owner->getAttribute($this->imageAttribute));
    }
419492
private function buildUrl($url)
    {
        // URI template (absolute or relative)
        if (!is_array($url)) {
            return strpos($url, '://')
                ? (string) $url
                : (string) $this->baseUrl->combine($url);
        }

        if (!isset($url[1])) {
            throw new \InvalidArgumentException('You must provide a hash of '
                . 'varname options in the second element of a URL array.');
        }

        // Absolute URL
        if (strpos($url[0], '://')) {
            return Utils::uriTemplate($url[0], $url[1]);
        }

        // Combine the relative URL with the base URL
        return (string) $this->baseUrl->combine(
            Utils::uriTemplate($url[0], $url[1])
        );
    }
1007174
public function setImage($imageUrl)
    {
        $this->openGraph()->setImage($imageUrl);
        $this->twitter()->addImage($imageUrl);

        return $this;
    }
490771
public static function createFromString($url)
    {
        if (!is_string($url)) {
            throw new \InvalidArgumentException(
                "invalid value provided for 'url'; expecting a string"
            );
        }

        $ret = new Url;
        if (($url = trim($url)) === '') {
            return $ret;
        }

        if (($url = parse_url($url)) === false) {
            throw new \InvalidArgumentException(
                "invalid value provided for 'url'; ".
                "url parsing failed"
            );
        }

        foreach ($url as $k => $v) {
            $fn = 'set'.ucfirst($k);
            call_user_func([$ret, $fn], $v);
        }
        return $ret;
    }
305296
static public function getUploadUrl($isAbsolute=true)
    {
        $url = static::getCommon('uploadUrl');
        if ($isAbsolute && strpos($url, 'http') !== 0) {
            $baseUrl = static::getRootUrl();
            $url = rtrim($baseUrl, '/') . '/' . trim($url, '/');
        }
        
        return $url;
    }
160807
public function getArguments($asString = false)
    {
        if ($asString) {
            $str = (string) $this->arguments;
            return $str;
        }
        return $this->arguments->all();
    }