This will lock uploads to “Uploaded to this post” and will not show “All media items” or other options in WordPress media panels.
Add this code to your function.php
file
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');
jQuery('#media-attachment-filters').remove();
});
</script>
<?php }
Related Posts:
- How to Fix HTTP Error When Uploading Images?
- How can I bulk delete media and attachments using WP-CLI?
- Expanding new Media Uploader in WordPress 3.5
- Get all posts (of any post type) an attachment is used in
- Password protect some uploaded files, so only logged-in users can view them
- Unattaching unlinked images
- Saving Custom Field in Attachment Window in WordPress 3.5
- Get url from file uploaded in Media Library
- How to retrieve alt attribute for an attachment (uploaded image)?
- Thumbnails generated from PDF in the “Media” section – how to show them in theme template?
- How to fetch only media that was already attached to a post/page?
- Audio file’s length (duration) is missing from Attachment Details in Media Library [closed]
- Attach media to multiple posts
- How do I modify the “Insert Media” lightbox in the admin to only show media items from a category?
- Add PDF to ACF image field from file url
- Organize media library into folders and get folders via WP Rest API?
- What is the way to add additional fields to attachments in 3.5+?
- Get images attached to a specific page
- ACF and Gravity Form file upload frontend [closed]
- WordPress Attachments with old images
- get all images from the wordpress media library with link to the post they are associated with
- How can i set media attachments to the author of the post or page for already existed posts with attachments
- How to add a custom field for image in “Text and Full Image(text right)” layout?
- Shortcode for Custom Field of Media Attachment (to use with Featured Images)
- Two problems that are likely related to AJAX
- Custom field in media library not saving, selected() function not adding “selected” to select list input type
- Media Library Mess After FTP … /uploads
- Which is faster: Loading images from the repo, or loading them using ACF Image Content via Media Library
- Adding attachment custom field metadata to TinyMCE tag
- controlling whether upload is attached to post or not
- Media library only show 2 items per page?
- Parsing value from Lottie JSON file
- How to manage attachment relationships for specific posts in WP 3.5+
- How to use taxonomies on attachments with the new Media Library?
- Rendering the uploaded file in a wp.media object
- Filter by post category in Media Library
- Hide old attachments from wp media library
- How to get all files inserted (but not attached) to a post
- How to protect uploads in multisite if user is not logged in?
- How do I control video media display sizing with native wordpress player
- Handle lots of images within the media uploader / selector
- How to add a custom field to quick edit
- Gutenberg First Block on Page Conditional?
- Get attachments by user
- How to order by just the Time Field in Advanced Custom Fields
- Using Gutenberg parse_blocks Function With ACF Custom Blocks?
- Add select field to media uploader that adds a class to the image
- Perform a custom (bulk) action in media view
- How to update custom taxonomy meta using ACF update_field() function or any other wordpress function
- How to count ACF Flexible Content Rows?
- How to write PHP array to render JSON-LD Markup for Job Postings, with ACF
- How can I store a file in the database in the same way WordPress and ACF do?
- Add up values from ACF number field
- Advanced Custom Fields: Conditional Statement with Select
- Media Manager: refresh library after new selection
- Display attachments by the ID of the post being edited in the wp.media frame (frontend)
- Bulk-Update Custom Posts
- Group ACF repeater fields from differrent posts
- Allow Editor Role to Edit Media
- Bulk image importing from folders
- ACF Add fields values to newly inserted post [closed]
- Programatically re-order images in the ACF gallery add-on. Orderby Title, ID, etc
- Returning data instead of echoing/printing
- upload_max_filesize is set to 64 MB already but WordPress is still showing 2 MB
- ACF: If field contain a specific value, update value in another field programatically
- how to load random related posts with specific custom fields?
- How to disable (and hide) the Media Library for certain users?
- ACF Image field not displaying in WordPress with Visual Composer [closed]
- How to acquire an ACF image using get_previous_post and get_next_post
- Building large multi-section pages with Advanced Custom Fields
- Showing a post depending on the Custom Field value
- Widget Code / Advanced Custom Fields / Elementor
- Trying to update repeater field (ACF) dynamically with data from Contact Forms 7
- Get title color from category custom field
- Efficient way to move media folder to another folder
- How to get a product’s Custom Fields in a different template file?
- Get all image in media Gallery with alt/title?
- Make inline uploader (plupload) on options page upload to a specific folder
- pre_get_posts hook not targeting search results page query
- ACF – get custom taxonomy term image field
- ACF group field disappeared after deployment using deployer script
- How to add HTML into error message
- ACF Dynamic select not showing data
- Modification of RSS feed is not consistent
- How to use WP Backery on Wysiwyg ACF
- Help using an array in ‘exclude’ key of another array
- What is wrong with my wp_insert_attachment code?
- Setting an image as post header (not featured image)
- Front page showing ACF only once, is that solvable to show the ACF per post? [closed]
- Add column and acf field content for cpt
- Organising and display thousands of photos in media library
- Is there a way to add Reattach and Unattach links in image gallery?
- Multiple loop issue – pull one featured and then continue the loop
- Check if meta_key exists in wp_list_pages
- Edit Image/Image Details – Replace button missing
- How can I attach files without using a plugin?
- Blurry Images WordPress 5.8.1
- PHP calls to custom fields not being made. Query seems to be blocking them
- Advanced Custom Fields – Issue with Slick Slider in ACF v6 Block
- How can I update an ACF field in a repeater on post save?