I am not sure is this what you are looking for. This code will “lock” uploads to show only “Uploaded to this post” in media panel
add_action( 'admin_footer-post-new.php', 'firmasite_mediapanel_lock_uploaded' );
add_action( 'admin_footer-post.php', 'firmasite_mediapanel_lock_uploaded' );
function firmasite_mediapanel_lock_uploaded() { ?>
<script type="text/javascript">
jQuery(document).on("DOMNodeInserted", function(){
// Lock uploads to "Uploaded to this post"
jQuery('select.attachment-filters [value="uploaded"]').attr( 'selected', true ).parent().trigger('change');
});
</script>
<?php }
Related Posts:
- Trigger refresh for new media manager in 3.5
- Is it possible to trigger some JavaScript when Media Popup is opened?
- Disable media library tab for non admins in uploader screen
- Trying to add filename over image in Media Browser
- How to change the image size in new Media Uploader (ie use medium vs thumbnail)
- Use custom image size in admin panel
- Display attachments by the ID of the post being edited in the wp.media frame (frontend)
- WordPress 4.9.8 Trying to add filename over image in Media Browser
- How to get the return value of wp.media({ frame: ‘post’ }) in all cases?
- Open Media Uploader Link in single post or page
- Physical organization of wordpress media library (Real Media Library plugin)
- How to show all available images in WP’s media library when using the Polylang plugin?
- Users can’t upload images on frontend if they haven’t got access to the wp backend
- Which filters or actions to use after a media upload and delete?
- Protecting direct access to PDF and ZIP unless user logged in (without plugin)
- Refresh wp.media after ajax call
- Why are double-periods (“..”) invalid in a WordPress image filename?
- Password protect some uploaded files, so only logged-in users can view them
- How to protect uploads in multisite if user is not logged in?
- Append button to WordPress Image Details modal
- Change URLs for static content
- Modify the array of selected images in media modal
- add_image_size creating lots of images (of various sizes)
- Add new media uploader at frontend for wp 3.5+
- How to disable WordPress Media resize different size version?
- Image uploading stuck on “crunching”
- Change the size of the image preview on the media edit page
- Media library storing files in uploads not folders within in uploads
- Add select field to media uploader that adds a class to the image
- Is there a limit on the number of attachments?
- How to host different file formats/types for a media attachment without creating multiple attachments?
- Site icons with alpha channel for self-hosted WordPress blog network
- how to use media library [closed]
- Can I stop wordpress generating media sizes
- Replacing Images in Media Library
- How to upload unknown file type?
- Is it possible to hide media details sidebar when wp.media popup is being opened?
- Adding Media Upload to Custom Options Panel breaks “Insert into Post”
- Calling WP Gallery Uploader/Selector From Metabox
- How to enable sorting in custom media uploader in plugin
- Restrict WordPress Media Library for a specific user role (users can only see/select own media)
- Update image via WP REST API
- Media Library does not show the uploaded image
- Attach Thumbnail Generated from Video Upload as Featured Image for the Video
- move_uploaded_file() not working on wordpress front end
- Stop WordPress from generating redundant image size
- Convert (-) and (escape) signs to (_) when uploading files on wordpress media library automatically
- How to submit data between wp_iframe and backbone.js in media upload
- Uploading .mp3 files http error – 2 “exact” files one successful other fails
- Media library only shows for admin. Doesn’t show editor or below [closed]
- WordPress Uploads Directory not using dates in links
- Set post_parent value for the images uploaded by Add Media button into post
- Get File Object from wp.Uploader
- Capability to prevent upload of files
- Original image not saving?
- Restrict role to view own media
- Multi Upload In Theme Options
- How to load attachment in media library for current user?
- How To Watermark Audio
- Resize existing library images
- Storing WordPress Media Library Uploaded files onto a separate domain
- Media Library Won’t Display Any Images
- A link (not in the post) to download a specific PDF file
- Issue with images which have no sizes available
- More Fields & Media Upload
- Migrating media files (documents only) to a fresh install and maintaining the same directory structure
- How does wordpress handle media files?
- WordPress media upload issue could not insert attachment into the database
- Set different max upload size limits based on file type/extension
- Correctly using the root directory for media uploads?
- Thumbnail images missing in WP media library
- What is the URL pattern for image thumbnails + sizes?
- Changing titles in Uploader for “Posts”
- How to detect when a file has been uploaded?
- What if I have a large file on the server that I want the wp library to have?
- Multiple images are generated in WP-content in wordpress
- Removing extra large generated images disables all crops
- How Do I Change the File Permission For Uploaded Files in WordPress?
- MIME types not recognized by media library
- Restrict Users to Only Edit Media Owned by Users in Their Role
- image not display in media library and thumbnail not display in post
- Images uploaded via Gutenberg image block are cropped
- Bulk upload images in upload folder does not show in media library
- Using Gravity Forms to upload media into library, then attach to post
- Import all media referenced in posts
- Redimension thumbnail crop without creating new images
- Issues with WordPress 3.9.6 media libraries on XAMPP
- Private file system for attachments
- WordPress Media manager select file button, how to prevent hiding?
- Insert into post or
- How to split my uploaded media into directories?
- Metabox with file upload to custom directory
- Is there a way to force Featured image to show as attachement?
- Link or button to open the media manager from frontend
- Bring up the media uploader on click
- Retroactively change Permalinks for media files after disabling year/month format
- How can comments be turned off for media attachments on WordPress?
- Question regarding the file path for media_sideload_image and wp_upload_dir()
- How do I restore attachment from files in wp-upload
- Image in binary in the data to WordPress media library