@param bool $embed

@return Url
555264
public function withEmbed(bool $embed): self
    {
        if ($this->embed == $embed) {
            return $this;
        }

        $url = clone $this;
        $url->embed = $embed;

        return $url;
    }
614080
public static function getVimeoEmbedUrl( $videoUrl )
    {
        $embedLink = '';
        $embedINI = eZINI::instance( 'embedtag.ini' );

        preg_match( self::VIMEO_VIDEOID_REGEXP, $videoUrl, $matches );
        if ( isset( $matches['videoId'] ) )
        {
            $embedLink = str_replace( '$$$VIDEO$$$', $matches['videoId'], $embedINI->variable( 'VimeoSettings', 'EmbedLinkPattern' ) );
        }

        return array( 'result' => $embedLink );
    }
812518
private function embedResource(array $embeds, ResourceObject $ro, array $query)
    {
        foreach ($embeds as $embed) {
            /* @var $embed Embed */
            if (! $embed instanceof Embed) {
                continue;
            }
            try {
                $templateUri = $this->getFullUri($embed->src, $ro);
                $uri = uri_template($templateUri, $query);
                $ro->body[$embed->rel] = clone $this->resource->get->uri($uri);
            } catch (BadRequestException $e) {
                // wrap ResourceNotFound or Uri exception
                throw new EmbedException($embed->src, 500, $e);
            }
        }
    }
494047
public function editor_css_url($encoded=true) {
        global $CFG;
        $rev = theme_get_revision();
        if ($rev > -1) {
            $themesubrevision = theme_get_sub_revision_for_theme($this->name);

            // Provide the sub revision to allow us to invalidate cached theme CSS
            // on a per theme basis, rather than globally.
            if ($themesubrevision && $themesubrevision > 0) {
                $rev .= "_{$themesubrevision}";
            }

            $url = new moodle_url("/theme/styles.php");
            if (!empty($CFG->slasharguments)) {
                $url->set_slashargument('/'.$this->name.'/'.$rev.'/editor', 'noparam', true);
            } else {
                $url->params(array('theme'=>$this->name,'rev'=>$rev, 'type'=>'editor'));
            }
        } else {
            $params = array('theme'=>$this->name, 'type'=>'editor');
            $url = new moodle_url('/theme/styles_debug.php', $params);
        }
        return $url;
    }
958450
protected function serializeEmbedOne(EmbedMetadata $embedMeta, Embed $embed = null)
    {
        if (null === $embed) {
            return;
        }
        $serialized = [];
        foreach ($embedMeta->getAttributes() as $key => $attrMeta) {
            $serialized[$key] = $this->serializeAttribute($embed->get($key), $attrMeta);
        }
        foreach ($embedMeta->getEmbeds() as $key => $embeddedPropMeta) {
            $serialized[$key] = $this->serializeEmbed($embed->get($key), $embeddedPropMeta);
        }

        return empty($serialized) ? null : $serialized;
    }
1087592
public function openStreamFeed($streamName, EntryEmbedMode $embedMode = null): StreamFeed
    {
        $url = $this->getStreamUrl($streamName);

        return $this->readStreamFeed($url, $embedMode);
    }
178611
public function getBaseUrl(bool $withHostName = false):string
    {
        if (!$this->baseUrl) {
            $this->baseUrl = dirname(filter_input(INPUT_SERVER, 'SCRIPT_NAME'));
        }
        return ($withHostName ? self::getHttpHost() : '') . $this->baseUrl;
    }
856034
public function url($include_host = false)
    {
        if ($include_host) {
            return $this->url;
        }

        $url = str_replace($this->base, '', rtrim($this->url, '/'));

        return $url ?: '/';
    }
1359310
public function embed($keep_resource = false) {
		ob_start();

		switch ($this->_output_format) {
			case 'jpeg' :
			case 'jpg'  :
				imagejpeg($this->_image_resource);
				break;
			case 'png':
				imagepng($this->_image_resource);
				break;
			case 'gif':
				imagegif($this->_image_resource);
				break;
		}

		$str = ob_get_contents();

		ob_end_clean();

		if (!$keep_resource) {
			imagedestroy($this->_image_resource);
		}

		return 'data:image/' . $this->_output_format . ';base64,' . base64_encode($str);
	}
1273326
public function getEmbed($key)
    {
        if (!isset($this->embeds[$key])) {
            return null;
        }
        return $this->embeds[$key];
    }
867633
public static function get_video_embed_url( $url ) {
		if ( strpos( $url, 'youtube' ) !== false && strpos( $url, 'watch' ) !== false ) {
			$parts = wp_parse_url( $url );

			if ( is_array( $parts ) && isset( $parts['query'] ) ) {
				parse_str( $parts['query'] );
				if ( isset( $v ) ) {
					return 'https://www.youtube.com/embed/' . $v;
				}
			}
		}

		if ( strpos( $url, 'vimeo' ) !== false && strpos( $url, 'player' ) === false ) {
			$parts = wp_parse_url( $url );

			if ( is_array( $parts ) && isset( $parts['path'] ) ) {
				return 'https://player.vimeo.com/video' . $parts['path'];
			}
		}

		return $url;
	}
1138685
protected function validateEmbedSet($embedKey, $embedName)
    {
        $embededPropMeta = $this->getMetadata()->getEmbed($embedKey);
        $this->getStore()->validateEmbedSet($embededPropMeta->embedMeta, $embedName);
        return $this;
    }
128712
public function getUrl($includeQueryString = true)
    {
        $url = $this->getProtocol() . '://';
        $url .= $this->getHostname();

        $isAbnormalPort = ($this->isHttps() && $this->getPort() != 443) || (!$this->isHttps() && $this->getPort() != 80);

        if ($isAbnormalPort) {
            $url .= ':' . $this->getPort();
        }

        $url .= $this->getRequestUri($includeQueryString);
        return $url;
    }
959848
protected function extractConfiguration(DOMElement $embed)
    {
        $hash = [];
        $configElements = $embed->getElementsByTagName('ezconfig');

        if ($configElements->length) {
            $hash = $this->extractHash($configElements->item(0));
        }

        return $hash;
    }
87464
public function embedCodeFor(string $url)
    {
        if (!$parsedUrl = $this->embedder->parseUrl($url)) {
            return null;
        }

        return $parsedUrl->getEmbedCode();
    }
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();
    }
966211
public function url($body)
    {
        $re = '/window.location(\.assign|\.replace)\(["|\'](.+)["|\']/i';
        preg_match_all($re, $body, $matches);

        if (!empty($matches[2])) {
            return new Url($matches[2][0], true);
        }

        return false;
    }