A solution that works for me is to add a clause to the WordPress query when the media library is being displayed.
From browsing my WordPress database I noticed that the full path to wp_posts.post_type="attachment" is stored in the wp_posts.guid column.
add_filter('posts_where', 'limitMediaLibraryItems_56456', 10, 2 );
function limitMediaLibraryItems_56456($where, &$wp_query) {
global $pagenow, $wpdb;
// Do not modify $where for non-media library requests
if ($pagenow !== 'media-upload.php') {
return $where;
}
$where .= " AND {$wpdb->posts}.guid LIKE '%my-path-segment%'";
return $where;
}
Related Posts:
- Hide upload image fields for the different media upload popups
- I’m using add_meta_box() but want to include TinyMCE editor *and* Media Uploads for each box
- WordPress media uploader – upload tabs not hiding
- problem in uploading attachment to custom directory
- Redirect to another page using contact form 7? [closed]
- Can’t upload format files on media library
- Altered Media Library URLs
- How can I add a Description column to the media library browser screen?
- Modify existing plugin function using filter (without modifying the plugin directly)
- Rename UPLOADS folder with custom WP_CONTENT_DIR
- How to move wp-content (or uploads) outside of the WordPress directory
- Add more rows on media picker
- What is the proper way to apply the login_form_bottom filter?
- How to filter get_avatar?
- Ignore a filter on the media library
- Automatically wrap post image in div
- How-to inspect filter-able $vars?
- How to exclude certain widget from showing up on home/front page? [duplicate]
- media_handle_upload weird thing
- Looking to display non-image files in Gallery with logo specific to file type
- Custom Queries – Child Categories not showing up
- Custom search page and search by title, content and tag
- Customizing the default logout page of WordPress
- Is there a filter hook that I can use to change how taxonomy term names are displayed?
- How do I go straight to “Edit More Details” when clicking on an item in the media library?
- Syncing Avatars across multisite
- How to re-arrange media uploaded using : media_handle_upload() as per year / month
- Changing image URLs in media library
- How to retrieve alt attribute for an attachment (uploaded image)?
- How to insert a sitemap within a subsite when using WordPress multisite
- Add options to the “Screen Options” section on the “Menus” editor
- Add a InfoBox in the media upload window
- woocommerce_checkout_fields modifying existing billing_phone label created new field
- How to add an extra variable to login and authenticate it?
- changing font size and font of a custom message added after comment
- result from custom filter admin table list backend does not work
- custom upload directory only for plugin uploads
- Can I create my own custom Attachment Display Setting?
- Admin search post meta
- Upload restrictions – upload_mimes – filter: Adding multiple MIMEs for a single extension and adding multiple extensions for a single MIME type?
- Installing new theme on running site
- Combine two conditions in one statement syntax [closed]
- More Fields & Media Upload
- Possible to hook into Media Library preview File column and use a custom image?
- Get users based on month ACF datepicker field
- Dynamically Filtering Posts by Data Points – Any Pointers?
- How to allow .bin files upload?
- How to append custom text to the output of ‘categories widget’?
- Media Upload not working after hiding some elements from functions.php
- Filter causing loss of _wp_attachment_metadata
- How to Add Additional Search Button?
- Custom Register Link on Backend Form
- Personalized Gallery what are my options?
- Filter Media by attached page or blog post in Library
- How to make WordPress search page use a relative path
- Adding overlay search to wordpress using add action/filter
- How to add HTML into error message
- How to get the full product name by ignoring custom modification on it
- Moving Quantity after product description
- the temporary save folder is wrong
- Wrap WordPress Login Form in custom Div
- How to fix custom add menu page preventing media library from loading
- Post filter with multiple checkbox taxonomy terms
- How to append the excerpt to the content in the single post page?
- How do I enable the text editer in my WordPress theme? [closed]
- Show different pages on site depending on user choice
- Is there a way to limit multi upload in media upload box?
- Organizing the Media Library for Cleanup
- Custom display for homepage, tag and author pages
- Custom Link In WordPress Media “Attachment Details” Upload Screen
- Pre_Get_Posts order DESC not registering
- Apply `the_content’ filter to theme customisation live preview
- How can I create more “create attachment” custom field – any idea?
- Upload files in wordpress
- Custom image sizes ignored in WP 3.5
- WordPress uploads directory. Featured Images storage
- Add variable : 1 Week ago
- How to add filters to my site?
- Changing upload directory temporarily
- Can’t change WordPress / WooCommerce attribute value order
- Custom Walker: how to get ID in function start_lvl
- How to include own css on wordpress tinymce editor?
- How to make custom bulk actions work on the media/upload page?
- Can WP Customizer work with single pages or posts?
- Using WordPress functions on other sites
- How to Check Disk Space used by Media Library
- Preventing Search Engines Indexing Pages 2, 3 and More?
- where can i add custom script to stop header video from autoplay
- Retrieving and Storing Images Linked from Other Domains on Local Server?
- How to merge all my pages into one, while keeping a menu bar?
- How to use get_option() without any filter?
- Allow EPS file upload – two EPS files have different MIME types
- Is it possible to replace PHP with NodeJS?
- Media Uploader in custom path
- How to customize core admin pages within a theme?
- How to set post_id to 0 when you upload image via Add media button. (async-upload.php)
- Automatically check parents (in a taxonomy) when child is selected
- Adding custom field in all widgets, but at the top of the form, in admin area
- Always logged in even if remember me is unchecked?
- Adding posts to custom menu [closed]