The only way to do it is using a query filter I think
function wpse156319_posts_where( $where, $query ) {
global $wpdb;
$where .= $wpdb->prepare( ' AND (' . $wpdb->posts . '.post_parent = %s OR ' . $wpdb->posts . '.post_author = %s)', $_POST['id'], get_current_user_id() );
return $where;
}
which you just add in the ajax_query_attachments_args
instead of doing anything else
function filterMediaLibrary($query = array()) {
add_filter( 'posts_where', 'wpse156319_posts_where', 10, 2 );
return $query;
}
Seeing as it’s a one-off ajax query it shouldn’t need removing.
Related Posts:
- How to filter the image embed code based on link type
- Is it possible to enable the ‘Link To’ field under ‘Attachment Display Settings’ for a Featured Image?
- ‘Add Media’ to post – filter images
- Restricting users to view only media library items they have uploaded?
- Filter to remove image dimension attributes?
- Prevent WordPress from generating medium_large 768px size of image uploads?
- Filter for post_thumbnail: link to small src and add data-attribute [duplicate]
- Why does WP allow to view and media item as a page
- Upload media only to DB
- Remove Image Sizes in Media Settings Page
- Function to remove all classes on images inserted into posts?
- Get images attached to a specific page
- How can I use wp_save_image_editor_file filter?
- Cache DB queries result
- Why WordPress suddenly changed sizes of thumbnails?
- Is there a way in WordPress to convert images to WebP without a plugin?
- Automatically Insert alt attribute above image has h2
- How to stop WordPress from completely overriding my tags in my templates?
- Auto delete pictures in media library by age
- WordPress Attachments with old images
- Weird encoded error when using wp_generate_attachment_metadata()
- Allow SVG in WP step by step
- Show last 12 uploaded images on home page, but only from posts
- Prevent WP from wrapping html in caption shortcode after ‘image_send_editor’ filter is applied
- Disable image rename on upload
- Set Featured Image not opening – Stuck at loading
- How to remove “Image Information” and “post date/author” from a media page?
- How can I change the to for lazyload wp smilies
- How can i identify media uploaded to my website that is not being used anywhere anymore?
- image URL changed in wordpress
- Can’t seem to see images on my machine but can on the server
- Attachments without images
- get rid of random string before an for an image path on wordpress
- Serving Images from subdomain in wordpress
- How to display a warning when an uploaded image is too small?
- User uploads image as “Featured Image” but WordPress resizes it?
- Profile image does not upload
- WordPress append -1 to the image name
- How to change an image source when rendering on frontend?
- How to change Gallery image url in product page ? In function.php?
- Allow a specific user role I have created to only upload one image to his media library
- cant upload media/pictures to my wordpress site, cant upload anything to my database
- How to display the Media Library Items Upload date
- How to get title of images in post content
- Upload error on localhost (at minimum, not yet tested online)
- How to generate alt attributes with php / filters?
- Built-in image lazy loading: Does it come with a polyfill for older browsers?
- Images not loading on webpage, and links to other media give 404 Not Found
- unsharp thumbnails after uploading image
- Updated wordpress missing image upload area
- Post-processing of the image failed
- How to trigger “wp_handle_upload_prefilter” filter when uploading an image programatically?
- WordPress Link To Image Missing Dropdown
- Generate links on all images in posts – is there a hook?
- js alert in add_filter function for image_send_to_editor
- Use wget to find used images
- Modify media file markup output
- Unable to delete images in Media Library
- Dinamically modifying attributes of images on posts
- How to regularly backup and update WordPress website with lot of images?
- Newly uploaded images are not updating in featured image
- How to attach post ID to image links in WordPress tinymce editor
- wordpress images not showing properly
- image_send_to_editor filter – Unwanted paragraphs and line breaks
- Edit image itself
- How might one programmatically set the link for all images in all posts?
- Image filter works on attachement pages but not posts. I can’t get the image ID
- How do I display image files as links?
- Surround uploaded image link with div
- page displaying media caption shortcodes
- How do I embed youtube video via url in frontend posting
- Missing Images in Uploads Directory (Server Only)
- Removing image dimensions from `the_content`
- Rename uploads filenames to POST-ID on upload
- Set padding for all content except images and few more elements
- Broken Media Library
- Change image link in excerpt to point to post
- Aviary + WordPress Media
- Img src path from wp-admin
- Media Library is not loading on grid view in admin panel
- WP is showing wrong image dimensions
- Font size on image captions on mobile
- Blurry Images WordPress 5.8.1
- Why some images are not allowed to be edited only for thumbnails?
- I tried to move the featured image below the paragraphs but now it is displaying twice
- WordPress API, creating Featured Media from image url (nodejs)
- How to import external media items into wordpress media library (without using storage)
- Delete all thumbnails & regenerate them?
- How to add a link to media file for every image inserted in content?
- Uploading media to wordpress API with C# HttpClient
- Media Library Issues
- Replace image with its alt text?
- Get field added via attachment_fields_to_edit filter in Gutenberg
- Neither intermediate_image_sizes_advanced or intermediate_image_sizes filter is firing
- How to upload multiple images to use as gallery in Kirki Framework
- How to load only a certain type of image (functions.php)
- Remove tab on product for one category, keep but change image for another
- How do I display a PDF thumbnail as a link to the PDF without uploading the image
- Featured Image add tab
- ‘apply_filters’ is breaking some shortcodes/HTML but not all