There’s a PHP function, called getimagesize(), it can do what you’re looking for.
For example:
$url is the image url
$imgsize = @getimagesize( $url ); // @ is needed to prevent error messages
if ( $imgsize // is the variable is not false
&& $imgsize[0] > 0 // and if the img width is larger than 0
&& $imgsize[1] > 0 // and if the img height is larger than 0
)
{
// your file exists, write your code here
}
else
{
// your file is not available, write your code here
}
If you specify it more, I can make this look better for example into template.
Related Posts:
- remove or update add_image_size
- Default Image Link Removal
- How to copy and paste a picture found on the web to wordpress easily
- Graphing libraries for WordPress [closed]
- add_image_sizes ignoring crop sizes and using proportion
- Get attachment ID of author_meta image – Attachment Metadata
- get_intermediate_image_sizes Get the Size Names but How Do I Get the Sizes?
- Alter image output in content
- How can I remove the image attachment ALT field?
- custom image size with New Media Manager in wordpress 3.5
- Change html structure of all img tags in WordPress
- Uploading images: ‘ø’ get replaced with ‘ø’
- Get a list of all image sizes that match aspect ratio of original one
- Insert image in comment reply
- Randomly add a ‘ul’ list of images
- custom image dimensions (for gallery)
- Screenshot.png not showing up
- Include photos in WordPress blog posts without uploading to Media Library
- Thumbnails are bigger in size than the original image
- The the post id from image id
- function to show only featured image of the posts
- Image resize depending on orientation?
- Featured images not displaying at full resolution
- Check if the image exists in WordPress media library
- Is there any action/filter hook to use when an image gets edited in the editor?
- Faster way to put images into a blog post by using Add Media dialog
- Images will not display, when I call them up with html in wordpress, just two blank small spaces [closed]
- Force minimum image size and aspect ratio when uploading images
- Changing default img html markup but not in admin back-end?
- Retrieve an array of image URLs that belong to a gallery
- Change align classes for images
- Ho to add “Create Slider” option to default “Add Media” popup?
- Images in Blog List
- Fixing image names for a site being restored
- Upload Image using wp_insert_attachment and file url don’t have file extension
- Custom header tiling?
- Using featured img as div background
- How can I change get_the_post_thumbnail to make 100% width image?
- Native gallery sorting is ignored
- Display an icon with get_post_meta?
- Include WooCommerce 2’s prettyphoto scripts on all site pages
- Get custom thumbnail sizes [duplicate]
- Using Jetpack carousel w/o creating a gallery [closed]
- Where do I locate theme image files
- WordPress Facebook Open Graph plugin not working for 1 specific image [closed]
- Custom responsive ‘featured image’ sizes
- Random background image showing on website per click/load
- removing the featured image from the post
- Dynamic image crop in WP 3.0+?
- Warning : tempnam() [function.tempnam]: SAFE MODE Restriction in effect
- How to force WordPress to upscale images?
- How to stop WordPress from completely overriding my tags in my templates?
- Image text wrap not working properly on frontend
- WordPress cutting images size
- How can i add a section of category image upload during adding of category in wp admin area?
- Errors and warning with padlock sign when site moved to SSL
- remove enclosure url from feed
- How to make footer area transparent? Using Avada and WordPress [closed]
- Show last 12 uploaded images on home page, but only from posts
- Whats causing image quality to be degraded?
- Fancybox just loading small white square
- WordPress Resize Image and show as thumb in post
- Resize uploaded images [duplicate]
- Link to full-size image for subscriber only
- How to join Caption AND Description Meta Fields as one combined-caption in Image Block
- Fullscreen Page Background without Plugin [closed]
- Allow a specific user role I have created to only upload one image to his media library
- how to regenerate webp et-pb-portfolio-image
- How do I avoid color distortion of uploaded images?
- How to avoid images appear as post in google search?
- When upload a PNG a noise appears in the thumbnails
- How to auto add image caption from image alt?
- How to stop TinyMce from converting image url into ?
- How to automatically load an image inside the post, since it is present in uploads folder
- Generate links on all images in posts – is there a hook?
- Decide how Hero image appears on mobile
- Broken images/videos after migration – DIVI theme- works ok on Mac OS
- Can’t figure out how to get space around an image? [closed]
- Show images from TEXT section on PAGE wordpress
- Where to add my code to auto attach images to existing products
- Set WordPress to Create different images format later, not during upload
- If file exists with page slug name show image else nothing
- How might one programmatically set the link for all images in all posts?
- page displaying media caption shortcodes
- Display different Images depending on the current day
- How to add a credit line to a photo caption
- Slider do not add alt attribute. Cant get alt attribute from a media library!
- Broken image URL
- Uploading Images for a section
- Some images suddenly not appearing
- Paginate Gallery [closed]
- WordPress: Preload next post images
- Image not showing in an archive page
- Set add_image_size() greater than content width in media box
- Remote Image (from URL) as Media Library element
- Theme using masonry layout script rendering overlaped images in Google Chrome [closed]
- Why is inline CSS added to images automatically? [closed]
- Uncaught Error: Call to undefined function file_is_valid_image()
- Display first image’s caption
- The uploaded images are only full-size (original)