Advertisements

links_add_base_url

Definition:
function links_add_base_url( $content, $base, $attrs = array('src', 'href') {}

Add a Base url to relative links in passed content.
By default it supports the ‘src’ and ‘href’ attributes. However this can be changed via the 3rd param.

Parameters

  • string $content: String to search for links in.
  • string $base: The base URL to prefix to links.
  • array $attrs: The attributes which should be processed.

Return values

returns:The processed content.

Source code

function links_add_base_url( $content, $base, $attrs = array('src', 'href') ) {

	global $_links_add_base;

	$_links_add_base = $base;

	$attrs = implode('|', (array)$attrs);

	return preg_replace_callback( "!($attrs)=(['\"])(.+?)\\2!i", '_links_add_base', $content );

}

2245

Advertisements

No comments yet... Be the first to leave a reply!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: