The correct way of refreshing the content of the frame, as found in the WP core, is as below:
if(wp.media.frame.content.get()!==null){
wp.media.frame.content.get().collection.props.set({ignore: (+ new Date())});
wp.media.frame.content.get().options.selection.reset();
}else{
wp.media.frame.library.props.set({ignore: (+ new Date())});
}
You should always check of the content is available, else refresh the library.
Cheers!
Related Posts:
- Custom “Uploads” Dir: “Edit Image” in Media Library broken
- How to restrict images in v3.5 Media Library modal to only those from a specific post id?
- WP 3.5 media manager – how to create a working gallery frame
- Is it possible to trigger some JavaScript when Media Popup is opened?
- Disable media library tab for non admins in uploader screen
- Refresh wp.media after ajax call
- How to get the image url in the input box from media library?
- WP3.5 Media Uploader – how to make it accept multiple images?
- Trying to add filename over image in Media Browser
- How to change the image size in new Media Uploader (ie use medium vs thumbnail)
- Restrict file types in the uploader of a wp.media frame
- wp_enqueue_media() Will not load JS on the theme
- Switch between tabs on “Insert Media” dialog
- Use custom image size in admin panel
- Display attachments by the ID of the post being edited in the wp.media frame (frontend)
- WordPress 4.9.8 Trying to add filename over image in Media Browser
- How to get the return value of wp.media({ frame: ‘post’ }) in all cases?
- WordPress Media frame pre load images from ids
- Get File Object from wp.Uploader
- Open Media Uploader Link in single post or page
- Simplifying ‘Add Media’ Modal in front-end Content Editor
- Physical organization of wordpress media library (Real Media Library plugin)
- Extend Media Library
- WordPress 3.5: Setting custom “full URL path to files” in the Media Library?
- How to show all available images in WP’s media library when using the Polylang plugin?
- Give users a maximum upload capacity; limit the number of files a user can upload OR limit the number of files per upload
- Media upload finished hook
- Users can’t upload images on frontend if they haven’t got access to the wp backend
- How can I batch delete all unattached images with WP-CLI or other automated process?
- Which filters or actions to use after a media upload and delete?
- Display attachments by ID in a wp.media frame
- Media not actually deleted on disk when click “Permanent Delete”
- retrieve custom image sizes from media uploader javascript object
- Protecting direct access to PDF and ZIP unless user logged in (without plugin)
- How to wp_upload_bits() to a sub-folder?
- How to get attachment id as soon as it is uploaded through media uploader in jquery?
- “Add Media” only shows “Full Size” under Attachment Display Settings
- Where do the favicons for Media Files come from
- What might cause a POST to wp-admin/async-upload.php to return JSON >and< HTML?
- How to call WP3.5 Media Library manager?
- Why are double-periods (“..”) invalid in a WordPress image filename?
- How can I speed up a slow loading media library?
- Password protect some uploaded files, so only logged-in users can view them
- What to do with unattached logos and header uploaded via native wordpress uploader?
- How to protect uploads in multisite if user is not logged in?
- Trigger JS when featured image upload window is opened in admin
- Append button to WordPress Image Details modal
- Change URLs for static content
- uploading files to the uploads folder via ftp
- Add item to media library from blob or dataUrl
- Modify Custom Field in Media Library using JavaScript
- Modify the array of selected images in media modal
- add_image_size creating lots of images (of various sizes)
- Remove upload_files capability from a role but allow role to manage an avatar image
- Create custom tab in WordPress 5 media upload
- Restrict file uploads by extension?
- Add new media uploader at frontend for wp 3.5+
- How to Check Disk Space used by Media Library
- Filter medias from the Media Uploader (wp.media) modal with a post meta
- Plugin to Import Dropbox Files into Media Folder from the Cloud [closed]
- How to disable WordPress Media resize different size version?
- Image uploading stuck on “crunching”
- Add media attachment filter to custom wp.media frame
- Change the size of the image preview on the media edit page
- Media library storing files in uploads not folders within in uploads
- Add select field to media uploader that adds a class to the image
- Close the media-upload thickbox right after upload is finished?
- Is there a limit on the number of attachments?
- How to host different file formats/types for a media attachment without creating multiple attachments?
- WordPress won’t generate image sizes for certain images
- Refreshing collections in the admin media manager
- Resize the WP media Uploader iFrame
- Site icons with alpha channel for self-hosted WordPress blog network
- how to use media library [closed]
- Can I stop wordpress generating media sizes
- How do I get allowed Media Library upload file extension list?
- Cannot upload .mp3 file to wordpress media
- Only displaying zip files with wp media
- Replacing Images in Media Library
- How to upload unknown file type?
- Custom “Insert into Post” button
- How to use MediaUpload outside of editor
- Is it possible to hide media details sidebar when wp.media popup is being opened?
- Allow only attachment uploaded to current post
- Adding Media Upload to Custom Options Panel breaks “Insert into Post”
- Calling WP Gallery Uploader/Selector From Metabox
- How to enable sorting in custom media uploader in plugin
- Restrict WordPress Media Library for a specific user role (users can only see/select own media)
- Update image via WP REST API
- Uppload image from another source wp.media
- Prevent a folder from being shown within the media library
- Media Library does not show the uploaded image
- Is It Possible to Upload Certain Attachment Files To A Remote Server
- Error uploading image in WordPress
- Attach Thumbnail Generated from Video Upload as Featured Image for the Video
- move_uploaded_file() not working on wordpress front end
- Stop WordPress from generating redundant image size
- WordPress Issue : The uploaded file could not be moved to wp-content/uploads/
- Convert (-) and (escape) signs to (_) when uploading files on wordpress media library automatically
- wordpress media upload given An error occurred in the upload. Please try again later