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 Protect Uploads, if User is not Logged In?
- Add a menu item to WordPress 3.5 Media Manager
- Enhance Media Manager for Gallery
- How to manage attachment relationships for specific posts in WP 3.5+
- Programmatically adding images to media library
- Extend Media Library
- WordPress 3.5: Setting custom “full URL path to files” in the Media Library?
- Filtering multiple custom fields with WP REST API 2
- Delete an attachment in the WP media modal window
- Upload images to remote server
- How to trigger a refresh in the media modal
- How to use taxonomies on attachments with the new Media Library?
- Media library – Limit images to custom post type
- Custom collection in media manager?
- How to show all available images in WP’s media library when using the Polylang plugin?
- Delete Associated Media Upon Page Deletion
- How to import CSV into Custom Post Type custom fields?
- Media library to list images only user uploaded
- WordPress 3.5 Media Manager – add a button
- Programmatically adding images to the media library with wp_generate_attachment_metadata randomly fails
- Rendering the uploaded file in a wp.media object
- Uploaded images don’t show in Media Library if there are special characters in IPTC Keywords
- ACF – get fields from group
- Remove “Insert from URL” link in Media upload – WP 3.5
- Which filters or actions to use after a media upload and delete?
- Front end form to create a custom post with preview
- How do I force WordPress to show most recent version of images in the media library?
- WordPress Media Manager 3.5 – default link to
- Proper way to add a button to the top menu of the media library?
- update_post_meta and update_field ony working when saving the post
- Stop WordPress from reserving slugs for media items?
- How to get “Additional CSS Class” for ACF Gutenberg block
- Protecting direct access to PDF and ZIP unless user logged in (without plugin)
- Can I use the wp media uploader for my own plugin?
- How to wp_upload_bits() to a sub-folder?
- Open media frame and select an attachment
- Filter by post category in Media Library
- Change Media Uploader default directory
- Advanced Custom Fields select field : How to echo the label, not the value? [closed]
- display image size in media library screen
- How to hide media uploads by other users in the Media menu?
- “Add Media” only shows “Full Size” under Attachment Display Settings
- Where do the favicons for Media Files come from
- Update media file url in wordpress media library
- media_handle_upload for local files?
- ACF: get_field() returning false [closed]
- Put the media uploader in a metabox
- How to capture the selection:toggle event fired by wp.media
- Uploading Multiple Attachments From Front-End With A Description
- get_attached_media() returns empty array if media file already used by another post
- complex restriction of items in media library
- Edit image / Delete image link
- How could I add button next to “edit image” button in “Attachment Details”
- How can I append custom data to images in the editor?
- Is there a user-facing interface to edit an attachment’s permalink?
- How do I detach images from posts?
- Is it possible to trigger some JavaScript when Media Popup is opened?
- How to call WP3.5 Media Library manager?
- Generate a excerpt from an ACF-wysiwyg-field
- Creating a metabox to upload multiple images, Ignoring The Featured Image
- Hide old attachments from wp media library
- media_sideload_image file name?
- Changing the media library default tab
- How to get all files inserted (but not attached) to a post
- Custom function to rearrange attachments when creating posts – Almost there
- Adding custom fields to the header.php
- How to single click to download image in single post
- Attach Files Metabox