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
- How to upload WordPress Images to remote web server and display those images in WordPress gallery [closed]
- Can we have an ‘Update metadata’ button in Image Gallery for all image instances?
- Retrieving Meta from Image Attachment
- Add ALT attribute to Pin It Button image to pass HTML5 validation
- Make change in media library affect images in published articles
- How to export all content with feature images?
- Adding (image) caching to my Tumblr widget
- How to upload multiple files/images when developing a wordpress plugin?
- Image Manager Plugin [closed]
- Implementing an image hosting website using WordPress? [closed]
- Bulk Image Upload And Rerrange Functionality
- Is there a best practice remediation for PhpStorm’s warning that void function the_post_thumbnail is used?
- How to apply lazy loading in background images [closed]
- Woocommerce showing images blurry in description page
- Slider/text combination plugin
- Image change on hover
- How to write “alt” tag in image for wordpress code?
- Adding Static Image to WooCommerce Content-Single-Product template
- How do I get a post author’s image/avatar via RSS from another blog?
- In Woocommerce theme need to add custom external link [closed]
- Getting taxonomy images to display on single-post with their terms
- Cropping images from top center using Jetpack Photon
- Photo Gallery Plugin and Touch Devices
- Image crop, resize and compression plugin?
- How to Resize the Custom Post Images?
- Plugin that will let me specify a number of image sizes?
- How to limit image size for the entire website ? But without editing the post (css/plugin?!)
- Images under 1MB are not being compressed
- Skewed / slanted button within elementor [closed]
- How can I automatically download all images from all imported posts, place them on my new host, and replace all the links
- Plugin for an interactive image? [closed]
- Clear out old images, any advice?
- How to fix broken media library?
- 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
- Large amount image data transfer
- Couple of beginner’s questions [closed]
- Blurry images when loading the page first time
- Get Image Having the ID [closed]
- Image Galleries for website migrated from .com to .org
- Search by Attachment ID
- Overwrite add_image_size defined by theme
- 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
- Some images on WordPress site are suddenly gone
- Is there a way to insert multiple images into a post at the same time without using a gallery?
- Is there a Image Gallery which will load all my posted Images like twitter’s image grid?
- Multiple images per post – Show random image elsewhere
- Replace image urls(absolute instead of relative) by using filter in single page
- Multiple Post Thumbnails Plugin – Need help with code
- Looking for a photo management solution
- I’m having several WP issues, especially with missing images
- Simple sildeshow/image-upload plugin?
- Elementor Pro display featured image on section -> style -> image using shortcode
- Offer Download Links for Product Images
- Can export gallery but can’t import it Wp all import
- how to remove share button from image overlay
- Revision featured image
- Bulk Image Resize for Media Library, but for ENLARGING instead of Shrinking
- Allow webp use on website but disallow webp as featured image during post creation
- Optimal image size for wordpress?
- Copy/paste local images not working in WordPress
- How to add height and width to images on a page(using WP Bakery) to improve Google’s CLS score?
- Is classical wordpress eidtor a good option for me to include a large table with a large number of images on my webpage?
- Enlarge an image slider when click
- Get all image in media Gallery with alt/title?
- WordPress built-in compression of images? How well does it compare to Photoshop or Shortpixel?
- Is there a way to auto generate poster image for videos
- Optimise wordpress database using SQL after deleting registered images from Media Folder
- 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
- Do images in plugins automatically load?
- How to Upload images to a custom folder in upload folder using media uploader
- I need to register and resize images, safe to delete plugin afterwards?
- Displaying all the images from all of my articles
- what functions to use to resize images and create DB metadata for them after/during upload?
- Product Page loads terribly slow when product gallery images are added
- Use AJAX to fetch Current Post Thumbnail for WordPress when Uploaded throughMedia Uploader Frontend
- automatically set random featured image by category in wordpress on post
- Import 2000 posts from one website to another
- WP_get_image_editor resizing images in a foreach loop