I think this should work:
$attachments = get_children( array('post_parent' => get_the_ID(), 'post_type' => 'attachment', 'post_mime_type' => 'image') );
if ( $attachments ) {
// do conditional stuff here
}
Related Posts:
- NextGEN Conditional Statement [closed]
- How do I add a nested conditional within an echo – to use a default image if there isn’t one in the post?
- get attachment title based on attachment id
- Get Image Description
- Automatically replace original uploaded image with large image size
- Why is wp_get_attachment_image_src not working with my custom size (add_image_size)
- How to give image source in wordpress page editor?
- How to wrap WordPress image captions inside H2, H3 tags?
- How to crop image from image src in a specific size
- Making WordPress Gallery (.gallery-item) Responsive?
- Width 100%: Aspect ratio of image
- How do i upload an image and return the image id?
- Upload images using FTP and show them in media
- add_image_size() cropped only if width of the image matches or is higher
- Is it possible to prevent users from uploading small images?
- Applying class to links around self hosted images embedded to posts/pages
- How to Make WordPress Default gallery responsive on mobile?
- Why does wordpress generate more thumbnails than the 3 standard sizes?
- Pulling Post Image Attachments in WordPress 3.9
- How to add an image for unit testing?
- including image assets in widget
- Link Featured Thumb to Attachment Page, If Possible
- Different captions for the same image in multiple galleries. Edit Image in Gallery locally
- Is there a shortcut to change bulk BMP images to JPG images in a site?
- Is 700,00 jpgs too many for a WordPress site.?
- Change the RSS feed image
- WordPress Post featured image URL in the header
- Add instructions to featured image
- How do I get more image editing options in the admin?
- Plupload resize for worpdress
- HTTP Error when uploading files above 7mb unless using GD Image Editor
- Question about add_image_size()
- How to display a different image size for mobile
- Image resize using url parmater
- Photography Based Design – Multiple Images Per Post
- How to display / include a specific jpg on a page
- Grab remote images and update links in existing posts
- Store Snapshot created via wordpress to use with lightbox
- Get image URL after image created from canvas and sent to WP uploads with AJAX
- How can I use cached images in an AJAX response?
- Can’t get images to align with Gutenberg editor
- Show image EXIF info
- wp_customize_image_control deprecated add_tab alternative
- Retrieve image from content, assign it as a featured, and then remove it from the content
- Custom Loop, Match Category with Page: How to display post featured image?
- Modifying the HTML Output of Inserted Images
- Google verification challenge with file location
- How to check for images before echo
- Remove height attribute from wp_get_attachment
- How do I retrieve an image’s width and height using Advanced Custom Fields?
- wp get attachment image always gives me thumbnail
- Two “the_excerpt” questions
- Images are not showing after moving WordPress installation from server to localhost?
- Images are not showing up in “Uploaded to this post”
- Cache DB queries result
- Remove “%” from strings in serialized arrays in wp_postmeta
- Images not found after migrating WordPress website
- Adding srcset to an image in ajax
- Error uploading images in wordpress
- Disable Media File Image Link On Mobile Devices
- Set two default featured images
- Automatically generate missing images
- Capitilize Alt/Title Tag in Image HTML, Reorder HTML Output
- Apply nextgen-gallery lightbox effect [closed]
- VT-resize (great alternative to timthumb) : Errors cropping (litespeed, centos 6.3)
- Allow admin roles to add images to comment replies
- Calling two images at a time? A better way?
- Page speed error: “serve scaled images”
- Image Captions Have a 10px Extra Margin, And It’s Not CSS? [duplicate]
- Image.php Problem – Post Images Not Displaying In It
- How can i sorting and display image order by siz in media library?
- x2 images for retina?
- Apply manual image cropping not to thumbnail but medium_large size
- Trouble with Uploading and Displaying Images
- Load url image full size in thumbnail, medium, large size
- Image alt attribute
- Non-existent child page URLs redirects to the image attachment URL instead of throwing 404
- Images not loading on wordpress.org site
- WordPress can’t detect any thumbnails size?
- Remove image border in twentyeleven theme [closed]
- second featured post not displaying on page [closed]
- WordPress not choosing the right image from srcset
- how to remove / hide ‘featured image’ option from side menu
- 403 Forbidden when accessing image in wordpress
- For what does WP generate Thumbnails?
- Images are not shown
- Adding multiple images on my site – without using plugins [closed]
- Remove the height limit on wordpress 3.4.2
- Missing Images in Uploads Directory (Server Only)
- Image media upload problem in page editing modus?
- Is there a good way to use CMS images with CSS
- Upload image from other server without resize?
- Forcing absolute src links in the RSS feed
- where is images/image.jpg?
- Using the on-board image editor for featured images: edits are not being used
- change with CSS the color of an svg background image set with “background-image: url()”
- Img alt tag showing different value then entered
- What type to upload image within theme options?
- WordPress Theme: replace logo image with title site if file doesn´t exist on server
- Remove one srcset entry from wp_get_attachment_image