2 defaultLinkTo
LogMANOriginal edited this page 2019-05-02 21:05:43 +02:00

Automatically replaces any relative URL in a given string or DOM object (i.e. the one returned by getSimpleHTMLDOM) with an absolute URL.

defaultLinkTo ( mixed $content, string $server ) : object

Returns a DOM object (even if provided a string).

Remarks

  • Only handles <a> and <img> tags.

Example

$html = '<img src="/blob/master/README.md">';

$html = defaultLinkTo($html, 'https://www.github.com/rss-bridge/rss-bridge'); // Using custom server
$html = defaultLinkTo($html, $this->getURI()); // Using bridge URL

// Output
// <img src="https://www.github.com/rss-bridge/rss-bridge/blob/master/README.md">