Definition:
function wp_attachment_is_image( $post_id = 0 ) {}
Check if the attachment is an image.
Parameters
- int $post_id: Attachment ID
Source code
function wp_attachment_is_image( $post_id = 0 ) { $post_id = (int) $post_id; if ( !$post =& get_post( $post_id ) ) return false; if ( !$file = get_attached_file( $post->ID ) ) return false; $ext = preg_match('/\.([^.]+)$/', $file, $matches) ? strtolower($matches[1]) : false; $image_exts = array('jpg', 'jpeg', 'gif', 'png'); if ( 'image/' == substr($post->post_mime_type, 0, 6) || $ext && 'import' == $post->post_mime_type && in_array($ext, $image_exts) ) return true; return false; }
3425
No comments yet... Be the first to leave a reply!