I’m able to do the following in media modal:
var selection = wp.media.frame.state().get('selection'); // get selected collection
attachment = wp.media.attachment(id); // get attachment with id
attachment.fetch();
selection.add(attachment); // add attachment to selection collection
There should be .remove()
method or something similar.
Related Posts:
- Is it possible to trigger some JavaScript when Media Popup is opened?
- Refresh wp.media after ajax call
- Display attachments by the ID of the post being edited in the wp.media frame (frontend)
- How to get the return value of wp.media({ frame: ‘post’ }) in all cases?
- Capability to prevent upload of files
- Open Media Uploader Link in single post or page
- How to add new tab to media upload manager with custom set of images?
- How to make “Upload files”selected by default in Insert Media?
- Reject upload of wrong-sized images using the Media Uploader
- How to show all available images in WP’s media library when using the Polylang plugin?
- How to add a custom field to the media screen (image/gallery)?
- Saving Media – Which Hook is Fired?
- upload_async.php returns 500 error
- Which filters or actions to use after a media upload and delete?
- Protecting direct access to PDF and ZIP unless user logged in (without plugin)
- How to restrict images in v3.5 Media Library modal to only those from a specific post id?
- Set a maximum upload count for users on a specific user role
- Multisite, upload images directly to Amazon S3
- wp_editor with media buttons
- Force wordpress to see uploads folder media
- Append button to WordPress Image Details modal
- 3.5 media manager add CSS / JS to new ‘tab’ iframe content
- Media uploader not work properly [closed]
- wp_temp_dir does not change the /tmp temporary default directory
- Retrieving JSON data in ajax request from media uploader
- Maximum upload size changes in php.ini ignored – How to remove upload size limit?
- How to disable WordPress Media resize different size version?
- Whole bunch of errors on WP website – media upload, edit slugs, edit screen not working [closed]
- Media library storing files in uploads not folders within in uploads
- How to side load an image from a service
- How to host different file formats/types for a media attachment without creating multiple attachments?
- How To install AWS SDK for PHP in wordpress?
- How to delete uploads not in media library?
- Add fields to the WordPress media uploader
- Change default from “Attachment post URL” to “File URL” in Add Media
- Why does SVG upload in Media Library fail if the file does not have an XML tag at the beginning?
- media_handle_upload : undefined function?
- Site icons with alpha channel for self-hosted WordPress blog network
- Insert Image automatically when upload finishes wordpress media uploader
- Using subdomain to upload media/images etc on 2 different blogs
- Why would media_sideload_image() not work locally?
- Media upload not working on theme option in WordPress 3.8.1
- Calling WP Gallery Uploader/Selector From Metabox
- Restrict WordPress Media Library for a specific user role (users can only see/select own media)
- Media upload on WordPress changes title of image
- media_handle_upload() progress bar
- move_uploaded_file() not working on wordpress front end
- WordPress 4.9.8 Trying to add filename over image in Media Browser
- Convert (-) and (escape) signs to (_) when uploading files on wordpress media library automatically
- wrong media url in wordpress
- Move files from flat upload directory to organised by year / month
- Can’t manipulate media uploads
- Prevent small image sizes from being uploaded
- Protecting uploads not working
- Media library only shows for admin. Doesn’t show editor or below [closed]
- Upload featured image from front end using media-upload.php
- Get File Object from wp.Uploader
- Custom media uploader not showing library
- What is the way to add additional fields to attachments in 3.5+?
- tb_show not showing a media upload window . custom plugin
- How can I manage and limit disk usage for each author?
- File names are being overridden when uploading new media
- In the media Rest API, what is “missing_image_sizes”?
- Error: The uploaded file exceeds the upload_max_filesize directive in php.ini [duplicate]
- How can I modify the media upload form fields?
- A link (not in the post) to download a specific PDF file
- Migrating media files (documents only) to a fresh install and maintaining the same directory structure
- How does wordpress handle media files?
- upload_max_size doesn’t change
- limit media upload to once a day
- Better solution for managing media attachments with `wp_editor()`?
- Control resizing of uploaded images
- Do custom post type (CPT) attachments/media store the parent post ID?
- WordPress media has all disappeared on wp-admin but still on the server
- Missing a temporary folder not fixed
- How to remove media by filename?
- media_handle_upload() returns Specified file failed upload test
- WP media upload issues
- Media Library: Remove replace images of selected author
- Is there some way to find if media items are used anywhere on the site?
- Media uploads error
- How to upload multiple images using WP rest API to media?
- Media URL slugs without uploads folder path
- Frontend media shows “An error occurred in the upload. Please try again later.”
- Moving wp-content folder to public_html
- WP_Custom_Media_Control | Give ID to media file
- WP Add Media Button – Can I set the default size to Original/Full Size
- wp.media – media uploader – how to destroy instance of modal?
- Issues with WordPress 3.9.6 media libraries on XAMPP
- Force relative path in media library for LAN deployment
- WordPress Media manager select file button, how to prevent hiding?
- Used Duplicator to transfer a site. Now my media uploads aren’t working
- Insert into post or
- How to split my uploaded media into directories?
- All files unattached in Media Library
- WordPress media upload multiple images
- How to upload an image using media uploader and return the image link to javascript?
- Set featured link not showing
- wordpress 3.6 media manager cropping timestamp
- Image in binary in the data to WordPress media library