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?
- Prevent WordPress from generating medium_large 768px size of image uploads?
- Upload images to remote server
- How to set the default embed image size
- Change WordPress image URLs via filter
- Default Image Link Removal
- Remove title attribute from images
- hook into completed image upload filter
- How to reduce original image quality on upload?
- Use Media Library to manage galleries like Nextgen (with folders, albums, collections, tags, categories, terms…)
- Insert Images at Master Uniform Height
- Alter media caption/description conflict in WordPress?
- Restrict the number of images to upload per post
- How to display a shortcode caption somewhere other than the_content
- Upload images using FTP and show them in media
- Image size filtering in Media uploader according to custom post type
- add data-attribute to all images inside the_content()
- Media sizes aren’t being created – server config?
- Filter to modify post_title after image upload?
- How to store media files in subdomain
- Edit image preview is not displayed
- How to add a media with PHP
- How to make programmatic image upload generate thumbnail and sizes?
- Best way to strip character entities (%20 etc)
- What’s the best “insert all images” plugin?
- Different upload path per file type
- 3.5 media.editor: what is the event listener for choosing an image?
- Getting alt text of featured image
- Get image alt attribute just by image URL
- Is there a way to get attachment data?
- What’s the proper way to use the get_image_tag filter?
- Can I the caption shortcode to set caption to a data attribute, and with the image’s alignment intact?
- HTTP Error when uploading files above 7mb unless using GD Image Editor
- Change WordPress Media Manager
- Site migration – some images not displaying in Media Library
- Bulk edit of EXIF data for jpeg images uploaded in the media library?
- Upload media files to Amazon S3
- How can I create more upload paths, like a post corresponding to a post title folder used to store images of the same product
- WordPress automatically downscaled images larger that original
- How to open default wp image editor screen dynamically?
- How to add custom classes to figure element only if image has caption?
- add media button is not working
- Change wp-content/uploads to uploads/%postname%/%image%
- Post and featured image have the same name, why is the attachment (image) is showing and not the post?
- Caption and title in img alt tag are the same?
- Is it possible to change image size used for preview thumnail in Add Media popup
- Moving media library to the media library of completely different site
- 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
- Get images attached to a specific page
- Why WordPress suddenly changed sizes of thumbnails?
- Is there a way in WordPress to convert images to WebP without a plugin?
- How to stop WordPress from completely overriding my tags in my templates?
- 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
- 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
- Serving Images from subdomain in wordpress
- 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 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
- 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)
- 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
- 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?
- Generate links on all images in posts – is there a hook?
- 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 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
- Surround uploaded image link with div
- page displaying media caption shortcodes
- How do I embed youtube video via url in frontend posting
- Removing image dimensions from `the_content`
- Set padding for all content except images and few more elements
- Change image link in excerpt to point to post
- Media Library is not loading on grid view in admin panel
- Blurry Images WordPress 5.8.1
- I tried to move the featured image below the paragraphs but now it is displaying twice
- How to import external media items into wordpress media library (without using storage)
- Delete all thumbnails & regenerate them?
- 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