How to set post_id to 0 when you upload image via Add media button. (async-upload.php)
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.
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.
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.
Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.