How to set post_id to 0 when you upload image via Add media button which will make a requtest to async-upload.php
Instead of actual post_id?
Thank you.
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It only takes a minute to sign up.
Sign up to join this communityFinally 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.
Add Media
button, it will getpost_parent
ID as the parent page that contains my plugins shortcode. I'm thinking setting this to0
when people upload images and update it to newly created post when they click submit button.