Advertisements

is_local_attachment

Definition:
function is_local_attachment($url) {}

Check if the attachment URI is local one and is really an attachment.

Parameters

  • string $url: URL to check

Return values

returns:True on success, false on failure.

Source code

function is_local_attachment($url) {

	if (strpos($url, home_url()) === false)

		return false;

	if (strpos($url, home_url('/?attachment_id=')) !== false)

		return true;

	if ( $id = url_to_postid($url) ) {

		$post = & get_post($id);

		if ( 'attachment' == $post->post_type )

			return true;

	}

	return false;

}

2131

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: