Firstly you can upload the image using wp_media_handle as it returns attachment id.
Then try to add your desired metafields by passing the same id in each of them.
Related Posts:
- How can I add an image upload field directly to a custom write panel?
- Hook to get image filename when it is uploaded
- Is using custom table to suit business needs instead of transients a big hit to page load speed?
- Upload multiple images and insert them into custom html code
- Redirect to another page using contact form 7? [closed]
- Cleaning a filename after image sideloading a url that contains `%20`
- How to move an image in a plugin to the upload directory and make it as a media of wordpress?
- WordPress discards PNG file when uploading plugin file
- Hook for validating and rejecting frontend image upload
- Caption Shortcode: what filter to change the image size?
- Is it possible to convert various image types from remote URLs to WebP and then serve them immediately?
- Upload to a specific media folder created by FileBird Lite
- Default table collation on plugin activation?
- Optimize shortcode callbacks
- Change Media Uploader default directory
- Getting wrong relationship value in $args in wp_Query?
- Not sure the best way to save custom plugin data
- The ideal place for storing persistent PHP objects
- How do I make specific plugin functionality apply to different sites in a network?
- What is the added “complexity” of custom tables?
- Plugin development with unit tests
- Formatting of curly brackets array from WP database to get more readable output
- How to modify post content before writing to database?
- How to find attachment ID for first image in a post
- stray elements
- Pass javascript result to shortcode executer function
- Hello dolly type plugin that allows people to add their own
- Hook event for upload image in the menu
- Activation hook not creating table
- Is the usage of ON DELETE CASCADE wrong or not allowed on wordpress?
- Is there a better way to implement responsive images than what WordPress uses by default?
- Proper way to hook wp_get_attachment_url
- What for the tables ending with the meta used in database of wordpress?
- Sharing a common set of image files for media library, across all sites within multisite
- Get a custom table to an array
- I’m designing a plugin to create database indexes. Suggestions?
- What is the best way to embed an JS App in a WordPress Page?
- How should I store a log for my plugin
- How to create database table, add data, update and delete using wpdb via plugins?
- Secure Pages Best Practice
- Are there any scripts, classes, and/or functions built-in to WP for a plugin to export/import its saved data from wp_options?
- How to serve different thumbnails/images depending on users browser/platform
- Create a new post using rest api and save featured image using an external image url
- Why is the temporary upload always 4.1K
- Can’t upload image using media_sideload_image
- 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
- Wrap text around shortcode
- wp_nonce_field displaying twice
- How to handle shortcodes through plugin
- What is the best way to store a few fields?
- How to query custom db table?
- Delete data from database using row action
- When echoing my own shortcode, it keeps adding a 1 at the end of my blogpost
- How do I have now a duplicated user entry if this is not allowed (and I cannot replicate it)?
- Which is the better way to store images for the plugin?
- Automating the process of shortcode generation in a plugin – how is it done?
- Shortcode not appearing when used as post content in wp_insert_post() or possibly, shortcode not being registered at all
- How to create a digital product download link that can’t be used twice?
- Two different wordpress sites – same server and IP address. Gaining Access to database 1 of 2
- How to create ShortCode
- Images not found after migrating WordPress website
- add_filter img_caption_shortcode not implemented
- shortcode tags not working in do_shortcode
- What might be the reason of Couldn’t fetch mysqli_result on another domain?
- How to insert HTML/CSS/JS into my iframe plugin?
- Resize not resizing images with Capitial extension like JPG
- $wpdb->update Issue
- dbdelta failing with error: “WordPress database error Table ‘wp_2_myPlugin’ already exists
- Why doesn’t update_post_meta work for certain strings?
- Font size of HTML content
- Cannot output plugin twice with shortcode
- Error code when migrate
- Getting incorrect filepath inside custom block front-end output using @wordpress/create-block tutorial
- WPGut – Updating failed and shortcode?
- Trying to rename a file upload as the hash of file content on wordpress
- How to write a custom shortcode name book?
- Save media files (images) to database instead of the filesystem
- Home page is not loading, where in other pages are displaying on the site
- How can we stop showing short code in create or edit post section
- WordPress Fatal error: Uncaught Error: Call to undefined function dbDelta()
- WordPress Iframe for blog image
- Use admin-post to submit form data to external database
- pull data from wordpress database
- Ajax not working to insert, query and result data
- Filter the_content() to add custom figure tags
- How to add conent (text) to Add New pages form of admin in WordPress
- Post data in wp-admin to external database
- Changing upload directory for plugin uploads only
- How do you filter get_media_items by mime type in a custom media upload tab?
- Images not displaying on live server
- upload script in plugin development [duplicate]
- WordPress simple ‘Hello World’ plugin – problems
- How to create a database table in WordPress using PHP
- Shortcode rendered in preview, but empty in post
- How to display .ptm file in my WP site without JAVA
- Can I log the searches that are returning 404 in the DB?
- Programmatically creating posts based on external JSON feed (asynchronously)
- upload image to wordpress media library failed for custom post type