Well, I have finally figured it out. Using Mike’s example here, I just need to put this code wp.media.model.settings.post.id = 0
at this place :
event.preventDefault();
wp.media.model.settings.post.id = 0;
// If the media frame already exists, reopen it.
if ( file_frame ) {
file_frame.open();
return;
}
This will cause the image to be uploaded as ‘Unattached’. Hope this helps someone facing this problem in the future.
Related Posts:
- Uploaded images don’t show in Media Library if there are special characters in IPTC Keywords
- Get attachment ID of author_meta image – Attachment Metadata
- How do i upload an image and return the image id?
- Rename attachments during upload
- media_sideload_image with rewritten urls?
- Handling image uploads without thickbox
- Auto delete attachments that are older than x days
- Does wp_get_attachment_image_src also work with non-image files?
- Get images attached to a specific page
- WordPress Creates Unused (Unregistered) Image Sizes
- How to disable post-thumbnail from generation?
- Troubles with code for upload a image
- After I upload a file to library its name converted to dashes
- Upload unnattached image from frontend
- How to get WordPress to resize images for srcset?
- Programmatically adding images to media library
- Can I attach image to post without adding it to post?
- Each custom image size in custom upload directory?
- Rename files on upload
- How to copy and paste a picture found on the web to wordpress easily
- Automatically wrap post image in div
- copy attachment title to description and alt text
- Open the attachment details modal
- How to Display an Image Uploaded through a Meta Box in a Template?
- HTTP Error when trying to upload image
- Regex to turn embedded images in to attachments
- Uploading images to Media Library fails with Memory Exhausted
- How to add a media with PHP
- When Uploading JPEGs, Does WordPress Compress the Original Image?
- Regenerate missing _wp_attachment_metadata
- Make alt text required when setting a featured image
- Display one random image, but only if landscape
- get_attachment_id() only get id of first attached image after post update
- Is there a way to get attachment data?
- How to change image url?
- get the image of the post
- How to order images in a post in WordPress 3.3?
- How to set a contact forms total size limit
- Change WordPress Media Manager
- All Images on wordpress site broken
- Multiple images with Media Uploader on front-end
- Out of memory error reporting
- Multiple images in one attachment page
- How to keep WP from recompressing Full Size images
- Exclude images from “inserted into post” when trying to get attachments
- Alter the image, before save, of a particular image size
- WordPress automatically downscaled images larger that original
- Missing a temporary folder.error when image is uploaded in admin Set temporary Directory – WordPress 5.2.2
- WP fails to upload files to media library, /wp-admin/async-upload.php 403 forbidden
- Add a background image for Custom Post Type archives page
- Show image crop window on image upload
- Images attached to posts from library link to 404 error page
- Help to upload post attachments from Ajax
- Uploaded images not displaying in network site
- Change image name during uploading sequentially
- How to limit the number of images displayed in the media window?
- How to get the Gallery form/section just like in Gutenberg block?
- How do you import images from a URL in your post?
- after migration, newly uploaded images won’t show up
- How to test if there are no more previous or next image on attachment page?
- Image upload error?
- How to add “alt” attribute for image during upload at WP front-end?
- How to use getimagesize() of image upload?
- How to change image’s author via a function when using GravityForms uploader? [closed]
- Excluding post thumbnail from the attachment.php when using wordpress gallery
- Alter the image used for a user who has not uploaded a custom image yet
- Allow users to upload multiple images to their profile
- Serving Images from subdomain in wordpress
- User uploads image as “Featured Image” but WordPress resizes it?
- How to increase media image scale limit?
- WordPress PHP custom function is causing 500 Internal Server Error Connection Timeout
- SQL: How to find all attachments that are not used in any posts/pages/custom_post_types
- Can’t upload Images to WordPress – Error 500 Response
- Updated wordpress missing image upload area
- WordPress 4.4.2 upload give error, can’t write is upper directory allowed to be written
- How to trigger “wp_handle_upload_prefilter” filter when uploading an image programatically?
- Broken images in media library
- Images are not getting uploaded
- Get “Image CSS Class” value from the Advanced Options section
- Run command to optimize images after they get uploaded to WordPress
- Uploaded images not showing properly using wordpress
- Where to add my code to auto attach images to existing products
- Set WordPress to Create different images format later, not during upload
- Assigning image to Post-Type won’t work anymore: exceeded time?
- The most of the images don’t appear, although URLs are correct
- attachment.php & flexslider—linking thumbnail to specific image
- Add two images with Sweet Testimonials
- Upload button in metabox not working
- Import existing image as a single post
- Image attachement management – a philosophical question
- wp_get_attachment_link() add rel attribute if the link points to direct image
- Stop Attachment image names from taking top level permalink
- How do I change a Themes Header Image?
- Media Library is not loading on grid view in admin panel
- Blurry Images WordPress 5.8.1
- Media upload error
- My subdirectory sites images (except webP) are throwing to 404 page even they are exist
- Uncaught Error: Call to undefined function file_is_valid_image()
- How can I use an image from an external source without uploading it to the media library
- Remove one srcset entry from wp_get_attachment_image