Get url for image

@param $image
@param $alt
@param $extra
@param $default
@return null|string
@throws \Laranix\Support\Exception\InvalidTypeException
420356
public function url($image, ?string $alt = null, array $extra = [], bool $default = false): ?string
    {
        return $this->generateImagePayload($image, $alt, $extra, $default)->url ?? null;
    }
375963
public function firstImageUrl($text, $default = null)
    {
        $url = $default;

        if (!empty($text)) {
            preg_match('/< *img[^>]*src *= *["\']?([^"\']*)/i', $text, $matches);
        }

        if (!empty($matches) && isset($matches[1])) {
            $url = $matches[1];
        }

        return $url;
    }
821878
protected function getStorageUrl($image): string
    {
        if (is_array($image)) {
            array_unshift($image, 'storage');
        } else {
            $image = 'storage/' . ltrim($image);
        }

        return $this->url->to($image);
    }
597496
public static function getImageThumbTag( $image, $options = [] ) {

		// Use Image from DB
		if( isset( $image ) ) {

			$thumbUrl = $image->getThumbUrl();

			if( isset( $options[ 'class' ] ) ) {

				$class = $options[ 'class' ];

				return "<img class='$class' src='$thumbUrl'>";
			}
			else {

				return "<img src='$thumbUrl'>";
			}
		}
		else {

			// Use Image from web root directory
			if( isset( $options[ 'image' ] ) ) {

				$images = Yii::getAlias( '@images' );
				$img	= $options[ 'image' ];

				if( isset( $options[ 'class' ] ) ) {

					$class	= $options[ 'class' ];

					return "<img class='$class' src='$images/$img'>";
				}
				else {

					return "<img src='$images/$img'>";
				}
			}
			// Use icon
			else if( isset( $options[ 'icon' ] ) ) {

				$icon = $options[ 'icon' ];

				return "<span class='$icon'></span>";
			}
		}
	}
368134
public function get_return_url($default, $extras=null) {
        global $CFG;

        if (empty($this->type) or empty($this->plugin)) {
            return $default;
        }

        $url = $CFG->wwwroot.'/grade/'.$this->type.'/'.$this->plugin.'/index.php';
        $glue = '?';

        if (!empty($this->courseid)) {
            $url .= $glue.'id='.$this->courseid;
            $glue = '&amp;';
        }

        if (!empty($this->userid)) {
            $url .= $glue.'userid='.$this->userid;
            $glue = '&amp;';
        }

        if (!empty($this->groupid)) {
            $url .= $glue.'group='.$this->groupid;
            $glue = '&amp;';
        }

        if (!empty($this->page)) {
            $url .= $glue.'page='.$this->page;
            $glue = '&amp;';
        }

        if (!empty($extras)) {
            foreach ($extras as $key=>$value) {
                $url .= $glue.$key.'='.$value;
                $glue = '&amp;';
            }
        }

        return $url;
    }
763602
public function getAdditionalUrlParam($key)
	{
		$result = isset($this->_additionalUrlParams[$key]) ? $this->_additionalUrlParams[$key] : null;

		return $result;
	}
407532
public function getUrl($image, $imageQuery = NULL)
    {
        // Experimental support for absolute picture url when is relative generator url set
        if($imageQuery && Strings::startsWith($imageQuery, '//'))
        {
            $imageQuery = Strings::substring($imageQuery, 2);
            $imageUrl   = $this->getPictureGeneratorUrl($image, $imageQuery);

            if($this->isUrlRelative)
            {
                if($this->websiteUrl)
                {
                    return $this->websiteUrl . $imageUrl;
                }
                else
                {
                    return '//' . $_SERVER['SERVER_ADDR'] . $imageUrl;
                }
            }
            else
            {
                return $imageUrl;
            }
        }

        return $this->getPictureGeneratorUrl($image, $imageQuery);
    }
830530
public function exifFunc($image, $raw = false)
    {
        if (isset($this->grav['exif'])) {
            /** @var UniformResourceLocator $locator */
            $locator = $this->grav['locator'];

            if ($locator->isStream($image)) {
                $image = $locator->findResource($image);
            }

            $exif_reader = $this->grav['exif']->getReader();

            if ($image & file_exists($image) && $this->config->get('system.media.auto_metadata_exif') && $exif_reader) {

                $exif_data = $exif_reader->read($image);

                if ($exif_data) {
                    if ($raw) {
                        return $exif_data->getRawData();
                    }

                    return $exif_data->getData();
                }
            }
        }

        return null;
    }
53856
protected function prepareImage($picture, $alt = '') {
    $value = NULL;
    $files = $this->loadByUuid('file', $picture);

    if ($files instanceof File) {
      $value = [
        [
          'target_id' => $files->id(),
          'alt' => $alt ?: 'file' . $files->id(),
        ],
      ];
    }

    return $value;
  }
747554
public function getUploadUrl( $default = null ) {

		$prop = $this->properties[ self::PROP_UPLOAD_URL ];

		if( isset( $prop ) && strlen( $prop ) > 0 ) {

			return $prop;
		}

		return $default;
	}
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;
    }
824654
public static String getImageLink(String imagePath) {

        return CmsStringUtil.joinPaths(
            OpenCms.getSystemInfo().getContextPath(),
            "VAADIN/themes/opencms/img-extra",
            imagePath);
    }
1022389
public function getThumbImage($alias, $options=[])
    {
        $url = $this->getThumbUrl($alias);

        if (empty($url)) {
            return '';
        }

        if (empty($options['alt'])) {
            $options['alt'] = $this->alt;
        }

        return Html::img($url, $options);
    }
313391
protected function getLocalImageSettings(
        $image, ?string $alt, array $extra, bool $default, bool $storage = false
    ): ResourceSettings {
        if ($image instanceof LocalSettings) {
            $settings = $image;
        } elseif (is_array($image)) {
            if (!empty($extra)) {
                $image['extra'] = array_merge($image['extra'] ?? [], $extra);
            }

            $settings = new LocalSettings($image);
        } else {
            $settings = new LocalSettings([
                'image' => $image,
                'alt'   => $alt ?? $image,
                'extra' => $extra,
            ]);
        }

        $settings->theme        = $storage ? null : ($default ? $this->getDefaultTheme() : $this->getTheme());
        $settings->default      = $storage ? false : $default;
        $settings->url          = $storage ?
            $this->getStorageUrl($settings->image) :
            $this->getThemeResourceUrl($settings->image, $settings->theme);

        return $settings;
    }
1049612
public function image($path, $imagestyle_id = null, $absolute = false)
    {
        return $this->image->getUrl($path, $imagestyle_id, $absolute);
    }
1315297
public function getImagename(AbstractLocalImage $image = null)
    {
        if (null === $image) {
            return '';
        }
        if (null === $image->getFilename()) {
            return '';
        }

        return pathinfo($image->getFilename(), PATHINFO_FILENAME);
    }
100842
public function iShouldSeeAVailidThumbnailForImageWithAlternativeText($imageAlternativeText)
    {
        $image = $this->getXpath()->findXpath("//img[contains(@alt, '" . $imageAlternativeText . "')]");

        if (count($image) == 0) {
            throw new \Exception(sprintf('Image with an alternative text `%s` was not found', $imageAlternativeText));
        }

        $file = $image[0]->getAttribute('src');

        $client = new \Guzzle\Http\Client();
        $request = $client->get($this->locatePath($file));
        $response = $request->send();

        Assertion::equalTo(
            $response->getStatusCode(), 200
        );

        Assertion::assertRegexp(
            '/image\/(.*)/', $response->getHeader('content-type')->__toString()
        );
    }