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
- How to show all available images in WP’s media library when using the Polylang plugin?
- Users can’t upload images on frontend if they haven’t got access to the wp backend
- Which filters or actions to use after a media upload and delete?
- Display attachments by ID in a wp.media frame
- retrieve custom image sizes from media uploader javascript object
- Protecting direct access to PDF and ZIP unless user logged in (without plugin)
- How to get attachment id as soon as it is uploaded through media uploader in jquery?
- Where do the favicons for Media Files come from
- Why are double-periods (“..”) invalid in a WordPress image filename?
- How can I speed up a slow loading media library?
- What to do with unattached logos and header uploaded via native wordpress uploader?
- Add item to media library from blob or dataUrl
- Restrict file uploads by extension?
- Add new media uploader at frontend for wp 3.5+
- Plugin to Import Dropbox Files into Media Folder from the Cloud [closed]
- Media library storing files in uploads not folders within in uploads
- Is there a limit on the number of 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
- Can I stop wordpress generating media sizes
- Cannot upload .mp3 file to wordpress media
- Replacing Images in Media Library
- Custom “Insert into Post” button
- How to use MediaUpload outside of editor
- Calling WP Gallery Uploader/Selector From Metabox
- Restrict WordPress Media Library for a specific user role (users can only see/select own media)
- Prevent a folder from being shown within the media library
- Is It Possible to Upload Certain Attachment Files To A Remote Server
- Error uploading image in WordPress
- Stop WordPress from generating redundant image size
- WordPress Issue : The uploaded file could not be moved to wp-content/uploads/
- wordpress media upload given An error occurred in the upload. Please try again later
- After moving from complete AWS setup to a standalone WordPress Server, Media/Image Files are Broken
- Using wp_enqueue_media() with switch_to_blog() issue
- Duplicates and other problems in Media Library
- “send_to_editor” function returning pdf file name
- Media library only shows for admin. Doesn’t show editor or below [closed]
- Choosing images size when uploading
- Capability to prevent upload of files
- Redirect to another page using contact form 7? [closed]
- Resize existing library images
- upload_max_filesize in .user.ini Not Reflected in Media Upload
- A link (not in the post) to download a specific PDF file
- How to change format of file link ( Name ) when insert from media uploder
- Set different max upload size limits based on file type/extension
- Correctly using the root directory for media uploads?
- Organizing uploaded Media in permalink-based folder structure?
- Offload Media Library to other domain on a different server
- How to change the text of the “You are about to permanently delete these items…” alert message when deleting media from the media library?
- admin notice on Insert Media popup screen
- How to allow .bin files upload?
- What’s the best way to add taxonomy’s image in 2017?
- What is the URL pattern for image thumbnails + sizes?
- Add SWF file to wordpress through custom template
- How to detect when a file has been uploaded?
- Uploaded images result in a file url with full path on disk appended
- Multiple images are generated in WP-content in wordpress
- Removing extra large generated images disables all crops
- MIME types not recognized by media library
- Restrict Users to Only Edit Media Owned by Users in Their Role
- Images not displaying on site or media library
- Replicate Media Galley Edit view in Add Media View
- Front-End Upload media with category
- Bulk upload images in upload folder does not show in media library
- Media not displaying other users uploads – WordPress 4.9.2
- How to destroy or dispose wordpress uploder/manager?
- Upload Multiple Files With Multiple Fields And With media_handle_upload
- Insert into post or
- controlling whether upload is attached to post or not
- How to split my uploaded media into directories?
- Metabox with file upload to custom directory
- Attachment Metadata not updated while uploading audio files
- Is there a way to force Featured image to show as attachement?
- Link or button to open the media manager from frontend
- Problem uploading files, after changing domain name
- Unable to upload images using the Media Library
- Assign multiple categories to Media Library upload
- How can I add custom sizes for PDF thumbnails generation?