wp_attachment_is_image [ WordPress Function ]
wp_attachment_is_image ( $post_id = 0 )
| Parameters: |
|
| Returns: |
|
| Defined at: |
|
Soorgelijke functies: wp_get_attachment_image, wp_get_attachment_image_src, wp_edit_attachments_query, wp_get_attachment_link, wp_count_attachments
Check if the attachment is an image.
Source
<?php
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;
}
?>
Examples [ wp-snippets.com ]
Top Google zoekresultaten
- Function Reference/wp attachment is image « WordPress Codex
Description. This function determines if a post's attachment is an image. It returns TRUE if the attachment is an image, FALSE if not. The accepted file ...
codex.wordpress.org - Apply image_downsize filter before wp_attachment_is_image check in
The function image_downsize in wp-include/media.php calls wp_attachment_is_image, which must return true before applying the image_downsize filter.
core.trac.wordpress.org - wp_attachment_is_image (WordPress Function) - WPSeek.com
WordPress lookup for wp_attachment_is_image, a WordPress Function. wpseek. com is a WordPress-centric search tool for developers and theme authors.
wpseek.com - WordPress Attachments – Part 1 | mtekk's Crib
Oct 13, 2007 ... bool wp_attachment_is_image([$ID]) returns true if the attachment is an image, or false if not. Once again the id of the attachment may be ...
mtekk.us