function is_local_attachment($url) {}

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


  • 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;



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: Logo

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

Facebook photo

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

Connecting to %s

%d bloggers like this: