Switch language

wpseek.com
A WordPress-centric search engine for devs and theme authors




is_local_attachment [ WordPress Function ]

is_local_attachment ( $url )
Parameters:
  • (string) $url URL to check
Returns:
  • (bool) True on success, false on failure.
Defined at:



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

Source


<?php
function is_local_attachment($url) {
    if (
strpos($urlhome_url()) === false)
        return 
false;
    if (
strpos($urlhome_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;
}
?>

Examples [ wp-snippets.com ]

Top Google zoekresultaten

Meer ...

Gebruikersdiscussies [ wordpress.org ]

0 User Note(s)

Nog geen één. Wees de eerste!

Nieuw toevoegen ...



HTML5 Powered with CSS3 / Styling, Performance & Integration, and Semantics