You can just run a conditional check on the result of get_the_image()
. Either it will have returned an image or not.
if ( function_exists( 'get_the_image' ) ) {
$image = get_the_image(array('echo'=>false));
if( ! empty ( $image ) ) {
// do something with the image
} else {
// do something if there is no image
}
}
Related Posts:
- How can I make add_image_size() crop from the top?
- Thumbnail with different sizes
- Converting Attachment to Images?
- Add padding while generating thumbnail
- Redirect to another page using contact form 7? [closed]
- Plugin to hide image in excerpt
- Add “Featured Image” box in my plugin post page
- Scrape a webpage for image and add it to post
- Regenerate Thumbnails Plugin successfully updated my thumbnails but image src won’t change to new image size?
- Add_image_size not generating correct size
- How to hide featured images of all posts falling under the same category in wordpress?
- Upload Image with a file URL and show dynamically on Frontend
- insert og image link in wordpress post
- Display Multiple Photos as Featured Image when mouse moves on to it post
- WordPress create thumbnails on demand
- Does WordPress have a way of changing the ‘Natural’ size of uploaded images?
- How to force regenerate thumbnails in WordPress posts?
- Retrieve post thumbnails
- wp.media.view.ImageDetails – Save settings as HTML5 data-* attributes for image
- how to get path to images in the uploads folder to be used in a plugin
- Display (and manage) webcam images?
- Cropping, Re-sizing and Saving images from one folder to another folder in wordpress
- Automatically Import Image into Posts from URLs on the Web?
- How do I change the description of the same image which is to be found in multiple instances?
- How to select featured images for 1500 posts?
- How to extract images of post and pages excluding header and logo image in wordpress?
- Meteor Slides as header only for homepage and Use featured image of each page as header for respective pages
- Generated Images sizes do not match Media Settings Image Size
- Converting a simple plugin to be placed inside of functions.php
- How to get CMB2 to show a single image at a specific size
- How to change Thumbnail size of next Gen Gallery plugin?
- Set WordPress Featured Image For All Post Slugs Matching Image File Name in Specified Directory
- How do I create a full-bleed background image on text mouseover? [closed]
- AJAX image upload with a upload progress bar using media_handle_upload
- Is it possible to insert images directly from the server?
- Get the url of the full sized attachment image using post ID?
- How to add css class to a specific set of images?
- How do I make images clickable so as to enlarge them using lightbox?
- Adding Attachment Display Settings in custom media frame
- Advanced Custom Fields
- Why isn’t “background-image: url”working with Bootstrap carousel on WP?
- Find unused images?
- How to generate video out of images via WordPress plugin
- Image gallery plugin [closed]
- How to upload images to WP Panel keeping correct folder in FTP
- Inserting HTML tag with ACF into shortcode
- How can I implement an Add to Collection function on my Image Gallery to be downloaded later?
- Howto accurately position images with maximum flexibility?
- Show an image in my header.php
- How can I restrict image upload dimensions for non-admin WordPress users?
- Set featured image using javascript in post editor
- Can we have an ‘Update metadata’ button in Image Gallery for all image instances?
- Adding (image) caching to my Tumblr widget
- Image Manager Plugin [closed]
- Slider/text combination plugin
- Adding Static Image to WooCommerce Content-Single-Product template
- How do I get a post author’s image/avatar via RSS from another blog?
- Skewed / slanted button within elementor [closed]
- Plugin for an interactive image? [closed]
- How to accept images at multiple sizes and aspect ratios and display as standardized image size / ratio?
- How to get images using taxonomy ( WP Media Folder)
- adding Adsense’s In-Article Ads between images of blog post
- Image Galleries for website migrated from .com to .org
- JSON API Plugin not showing Attachments id reused
- How do I link an image in my plugin so it displays on WordPress?
- Adding featured image to posts created by a plugin
- Is there a way to insert multiple images into a post at the same time without using a gallery?
- Looking for a photo management solution
- I’m having several WP issues, especially with missing images
- Elementor Pro display featured image on section -> style -> image using shortcode
- Can export gallery but can’t import it Wp all import
- Bulk Image Resize for Media Library, but for ENLARGING instead of Shrinking
- Enlarge an image slider when click
- WordPress built-in compression of images? How well does it compare to Photoshop or Shortpixel?
- How to Add call button on a featured image in a wpsite? check the slap king image, there are two buttons on the featured image
- How to Upload images to a custom folder in upload folder using media uploader
- what functions to use to resize images and create DB metadata for them after/during upload?
- automatically set random featured image by category in wordpress on post
- Implementing Scrollable Images
- Uploading images to custom table
- Theme Load Error
- Images not showing on homepage after migration [duplicate]
- how to open image gallery in a post/page?
- Lazy Load sometimes don’t work
- Server Path Information
- Display alt text as tool tip on page
- Advanced Custom Field User Help URL
- featured image problem with custom post type
- How can I manage the background image of a slider based on the featured image of a page?
- getting image alt text via ACF plugin in WordPress [closed]
- Allow users to download media files directly from Amazon S3 (AWS plugin)
- How should I force WordPress to give proper name for the uploading images?
- How to display multiple images in the before and after plugin?
- Get URL for featured image for posts? [closed]
- How to Add a Website Background Image to One Page?
- Want to show pop up image on home page every time when i refresh it [closed]
- Multiple Post Thumbnails Not Returning URL for Background Image
- Achieve the following layout
- How To Convert External Image URLs To Own Website’s Uploaded Images Automatically?
- How do i display the number of images on the “post screen”