you can use this snippet to get the first image of a post attachment id:
$images =& get_children( 'post_type=attachment&post_mime_type=image&post_parent=" . $postID );
$attachment_id = $images[0]->ID;
Related Posts:
- Get attachments from a post
- Uploaded attachment not set as featured image
- Hook after attachment added and cropped
- Issue on Getting WP Gallery Items In cpt-single.php As Attachments
- How can I add an image upload field directly to a custom write panel?
- Custom collection in media manager?
- How to implement add_image_size in a plugin
- Can I use the wp media uploader for my own plugin?
- How to catch images with blank dimensions?
- Add an image gallery to a custom post type?
- Having Problem On Getting WP Post Gallery Images URL
- Set first image (external) as featured image / thumbnail
- Hook event for upload image in the menu
- How to get an image transferred via FTP or script to appear in Media Manager?
- Is it possible to modify the media library admin screen?
- Add media and attach images to pages
- Is there a better way to implement responsive images than what WordPress uses by default?
- Save image as featured image
- How to show large image in checkout page using WP Ecommerce plugin [closed]
- Hook to get image filename when it is uploaded
- How to send email in wordpress with more than one attachments
- Resizing Images for a Gallery-Plugin?
- get post attachment using ajax
- How to serve different thumbnails/images depending on users browser/platform
- how to get link of added document with a post
- How to Upload Images From a Folder (Not WP_Uploads)
- wp_set_object_terms not updating database without a die()
- How to export post meta with images in wordpress
- Putting a resized image into media library with wp_get_image_editor(
- Display list of uploaded images, filtered by user under a specific user group
- Upload multiple images and insert them into custom html code
- Which is the better way to store images for the plugin?
- Run a function when new image is uploaded in media library
- How do I change the image from the default mysteryman in the WP Profile page
- Conditional Generation of Image Sizes using add_image_size
- how to change image of jquery slider plugin
- WP Still Generating 150×150 Thumbnail Size Even After Un-Setting Small Size in Functions.php
- Cleaning a filename after image sideloading a url that contains `%20`
- How to list all images used on a specific page?
- Screenshots on plugin page taken old [closed]
- Resize not resizing images with Capitial extension like JPG
- How to move an image in a plugin to the upload directory and make it as a media of wordpress?
- The URL of images on my website changed after being set as featured image
- Getting incorrect filepath inside custom block front-end output using @wordpress/create-block tutorial
- WordPress Favicon not Working For Images/Videos/PDFs
- Adding the image selector/uploader to an admin back page
- WordPress discards PNG file when uploading plugin file
- Hook for validating and rejecting frontend image upload
- WordPress Iframe for blog image
- Replace the WordPress Media Library Uploader
- Unexpected issue when using attachment_fields_to_edit filter
- Caption Shortcode: what filter to change the image size?
- Filter the_content() to add custom figure tags
- How to show post attachment image
- Attach an image to new posts
- Is it possible to convert various image types from remote URLs to WebP and then serve them immediately?
- Images not displaying on live server
- Using “add_image_size” to register custom image sizes inside plugins not working
- Leveraging Core Functionality in Icon Upload Plugin [closed]
- Displaying an Uploaded Image as a Custom Avatar in WordPress
- Add a custom image source
- Upload to a specific media folder created by FileBird Lite
- How to add extra EXIF data when images are uploaded?
- Set srcset on a block image
- WP 3.3 How to Add Menu Items to the Admin Bar?
- Unit tests – Dealing with dependencies
- Should I create a theme or a plugin?
- How to add classes to images based on their categories?
- The changes I make to an external JS file of my WP plugin are only applied after I clear my browser’s cache
- How to add multiple copies of a widget from “available widgets”
- How do I approach removing menu items on the fly based on settings in my plugin?
- Can I use core’s “or Link to Existing Content” feature in my plugin?
- Plugin with specific admin menu icon
- Getting media library popup in custom plugin admin page
- Should I always prefer esc_attr_e & esc_html_e instead of _e?
- using new WP_Query in save_post function alters $post
- Preview Changes button missing on custom post type page since updating to 3.4
- How To Consistently Enforce Rewrite Rule in Plugin Development
- Warning: Cannot modify header information – How to resolve this issue? [closed]
- $paged always 0 on plugin’s custom page
- Is there a way in which I can compare product id with the order id to display content on front end before placing the order? [closed]
- Video Security just like facebook [closed]
- Link Pop-up in custom plugin
- How to handle shortcodes through plugin
- WordPress debug messages not displaying
- Is there any way to fire heartbeat API from for website visitors?
- How can I prevent ‘500 internal server error’ because of a long install process?
- Displaying custom content from a plugin within the active theme
- Custom plugin & calling REST api of wordpress instance the plugins is running on
- Add variables from rewrite rules to query var
- How do I specify where to save the debug.log?
- Code for cron to delete posts that contain specific expression (e.g. “unable to fetch” every 30 minutes
- How to fetch the post content from the wordpress editor before it can be saved(published)?
- pull data from wordpress database
- How does one set cookies in WordPress without getting the ‘headers not sent’ error? within WP
- Glyphicons Dont Show in WordPress Plugin Only
- Change the search results header from plugin
- Add query string variables to all hyperlinks URL matching a specified domain
- Is there such a thing as a WordPress console?
- WooCommerce adds a newline symbol (\n) between email recipients