Finally found an answer for this and checked it worked on my situation.
How to upload image without post ID using the new media uploader?
// Set post_id to 0 when Add Media button clicked
jQuery('#insert-media-button').on('click', function( event ){
event.preventDefault();
wp.media.model.settings.post.id = 0;
});
This will set all the images uploaded via Add media button to 0 which will show up as (Unattached)
in backend.
Related Posts:
- How to allow to user non logged in WP system upload in media library?
- Distinguish between 2 instances of admin-ajax.php
- Load minimum WordPress environment
- admin-ajax.php returns 0. How do I debug it and fix it?
- Add item to media library from blob or dataUrl
- Plupload in metabox – AJAX action not working in Class
- AJAX action not triggering PHP function
- Using wp_handle_upload and media_handle_sideload with ajax
- How to know what page is calling admin-ajax.php?
- Ajax image upload with media_handle_upload and form.js
- wp_handle_upload returns empty error array
- Pass additional parameter with async upload
- How to disable drag-and-drop upload function in Media Library?
- Get uploaded attachment width & height and attachment ID after upload them
- Why is the file not uploading to the server?
- Filter images from media library by guid meta field
- How to locate the js code and php code for certain function?
- Make inline uploader (plupload) on options page upload to a specific folder
- Frontend AJAX Media Upload returning 404
- How to require files in a custom endpoint
- Cannot add multiple single images at once
- How to send custom variable in Media Uploader ajax request?
- wp_enqueue_media problem
- Is custom behaviour possible when asynchronously uploading?
- Google Maps API throws “Uncaught ReferenceError: google is not defined” only when using AJAX
- Initialize TinyMCE editor / visual editor after AJAX insert
- Checking if a file is already in the Media Library
- Displaying PHP Errors from admin-ajax.php
- wp_set_auth_cookie() doesn’t work in Ajax call
- Custom “Uploads” Dir: “Edit Image” in Media Library broken
- WP-AJAX vs WP REST API: What to use for requests to the website from outside?
- Is it safe to assume that a nonce may be validated more than once?
- Using Nonces for AJAX that only retrieves data
- How to protect uploads in multisite if user is not logged in?
- uploading files to the uploads folder via ftp
- Remove upload_files capability from a role but allow role to manage an avatar image
- post_id missing from the wp-admin file upload request
- Quick Edit: Selected Custom Taxonomy Not Refreshing After Save
- wp_verify_nonce always returns false when logged in as admin
- fetching via fetch/ajax gutenberg block data from third party
- Image uploading stuck on “crunching”
- Get attachments by user
- Conditional action hooks
- How to make get_theme_mod work with AJAX in the customizer preview
- How to check an ajax nonce in PHP
- Fatal error: Call to undefined function get_post() with ajax
- Is it possible to hide media details sidebar when wp.media popup is being opened?
- wp_create_nonce() in REST API makes user->ID zero
- Ajax simple experiment
- How to load new text widgets and polls into the sidebar without reloading the page?
- Admin ajax add tag callback
- Stop auto load wp-admin admin-ajax.php
- Save & Reset button in theme-option with Ajax (without refresh)
- Ajax Multi Response Problem
- AJAX call inside plugin class not triggering
- Custom AJAX Endpoint not returning any result
- Contact form 7 Hide response messages after 5 seconds
- upload_max_filesize is set to 64 MB already but WordPress is still showing 2 MB
- how should i get json encoded data from wordpress ajax action page
- Cache plugins and ajax nonce verification
- Ajax function on #publish only saves as draft – how to make it publish?
- AJAX call broken after actualization
- ajax problem – function on server is not called
- wp_mail doesn’t work when logged in?
- Need help with Access-Control-Allow-Origin
- Send email via ajax
- Load page HTML content through AJAX
- How to delete file uploaded by Plupload
- Error sending array data from php to javascript
- Sharing variables in both actions wp_footer and wp_ajax
- Display full WordPress post under search form using AJAX
- Ajax callback not work
- jQuery.post returns 0
- Opening Modal popup on Ajax form submission
- Ajax sometimes work and sometimes just don’t work
- admin-ajax error 400
- wordpress admin ajax trash_comment
- Failed to load resource: the server responded with a status of 404 (Not Found) admin-ajax.php
- What is wrong with my wp_insert_attachment code?
- Javascript output now showing in custom widget
- Editor User Role can’t see other users media
- Create a post with REST API and adding a category
- how to correctly use json_encode with ajax
- How to trigger lost password email using REST API?
- How to block search engines indexing certain AJAX actions
- wp_ajax_action, wp_ajax_nopriv_action not working
- Failed to load resource at admin screen
- Manually cache a special, non-WP-but-using-WP page (e.g. Ajax results) with W3TC
- Static var overwritten with WP AJAX action, works fine without AJAX
- How do I change a Themes Header Image?
- Edit Image/Image Details – Replace button missing
- Add frontend editor with media buttons for Visitors and display only their media
- Media Library is not loading on grid view in admin panel
- Blurry Images WordPress 5.8.1
- using ajax to query sql
- I want to customize wp.media (the wordpress admin uploader) in order to change the file name but only in video custom post type
- What does WordPress media uploader do to image files on upload?
- Adding custom fields to Wired Impact Volunteer Management Plugin
- Upload to a specific media folder created by FileBird Lite
- How to update my jquery/PHP function to add/remove user as favorites in (WordPress) users list