I’ve been searching for this answer too and found it using this answer. You just need to add a property to the library object:
var wpMedia = wp.media.frames.file_frame = wp.media({
'library': {
type: 'image',
custom_var: 'webhead'
},
'multiple': true
});
Then in PHP you can see the custom variable in the ajax_query_attachments_args
hook like so:
function webhead_ajax_query_attachments_args() {
var_dump($_REQUEST['query']['custom_var']);
exit;
}
add_filter( 'ajax_query_attachments_args', 'webhead_ajax_query_attachments_args' );
Related Posts:
- Delete an attachment in the WP media modal window
- Rendering the uploaded file in a wp.media object
- Run script after clicking Set Featured Image in Media
- WordPress Built In Dialog Box For My Plugin
- Media Manager: refresh library after new selection
- Media Manager (since 3.5): How to show an empty Media Library when creating a media frame?
- Extending wp.media.model, query media from different blog on network and refresh view
- Media Library modal customization
- How to create different media uploader frames / filter library depending on a custom action
- How to Protect Uploads, if User is not Logged In?
- Pre populate WordPress wp_media modal with image selection
- Enhance Media Manager for Gallery
- For what security reasons are svgs blocked in the media uploader?
- Add media with WP-Rest-API v2
- Media library to list images only user uploaded
- WordPress Image Editor not working – conflict?
- WordPress Media Manager 3.5 – default link to
- Is it possible to trigger some JavaScript when Media Popup is opened?
- Failed to import media from a local wordpress site to a live one
- Rename “Add Media” Button To “Add Images”
- How would I go about listing only unattached media in say a sidebar?
- Filter what image sizes get generated
- Restricting access to files within a specific folder [duplicate]
- Plugin to download attached media files?
- Uploading non-media files?
- Add media with WP-Rest-API v2 II
- Change WordPress’ media upload URL?
- Disable edit option in Media library
- WordPress 3.0 Media Upload Directory
- What table is the media’s sort order stored?
- Media is shown in listview but not in gridview whenever i activate my Custom Theme
- Add input to the media uploader and pass its value to each uploaded file
- Generated media have incorrect aspect ratio
- wp.media edit attachment screen
- What is the structure of the “Featured Image” field in the DB?
- File Type Is Not Permitted – Cronjob
- Add instructions For Media Library Uploads
- Cannot embed YouTube videos “Failed to embed” error
- How do I create a custom add media button modal?
- How to open default wp image editor screen dynamically?
- Finding a media attachment post ID from a URL
- How to upload media to a specific folder without a plugin in WordPress?
- Overriding of the template for the Attachment “thumbnails” in the Media Grid isn’t working
- Limit number of images to upload in wp.media function
- Moving media between blogs changes the URL subdirectory [closed]
- Error: Warning: strpos() in media.php
- Custom controller for video that is added from editor
- Password Protecting Media
- How to get media source of text editor in WordPress
- how to upload file to media library using link [closed]
- Allow downloading unusual file types
- Is it possible to change filenames in media library after upload?
- Passing jQuery into the WordPress media uploader
- Upload video in custom folder
- Media Library not showing images but still acknowledges existence
- RSS audio enclosures have length of zero (podcast duration is missing)
- Remove delete-attachment button for every media
- How to programatically toggle the media setting “Organize my uploads into month- and year-based folders”?
- Unable to add logo or header [closed]
- core/gallery get figcaption text
- Importing existing s3 Media into WP
- Import WordPress, Failed to import sizes
- Admin edit S3 Media file?
- When I insert media from Library into a post, can I then safely delete that media?
- Stylesheet being loaded outside of
- Attaching images to multiple galleries
- Woocommerce blank screen variable product attribute image thumbnail
- Specific folder and no thumbnail generation for media_sideload_image
- Whats wrong with my wp gallery?
- Set a minimum and maximum limit of images to select in the MediaUpload component for Block
- How to re-house images in uploads/YYYY/MM
- Pre-load images into a new users media gallery
- The uploaded file could not be moved to wp-content/uploads
- WP REST API Create media return Timeout Gateway in response, but media created
- How to Protect Uploads, if User is not Logged In?
- Creating multiple instances of Media Uploader
- Handle image file and save it to media
- Multisite has SSL certificate, but media library is still http://
- Direct media library upload saving in wrong month date folder in custom theme
- Insert Link to Audio versus Embed Audio Player
- Change behavior of the “ADD Media” buttom
- How to resize image in wordpress from backend? Seems like bug in wordpress
- Disable wordpress gif compression?
- wordpress doesnt add media.css file
- Change default ‘file not supported’ error message
- Extra metadata for media items
- Customize WordPress Upload Directory
- How to open full Media Editor in a frame
- Elegant way to signify inheritance and relationship between posts
- Media Player gone on front end
- Why does uploading a media file a second time restore older version?
- Get original path of user’s filesystem of an uploaded media
- add file name column to media library to sort by
- Active Directory and group permissions
- WordPress / Audio player
- gallery – size is thumbnail by default change it to medium [duplicate]
- Cache of site on browser
- How to batch-add image file extension without losing DB refs?
- How to add a column showing real media usage (count) to the media list view?
- Looking for a way to insert PDF image preview in TinyMCE