Skip to main content
10 votes

List of available events for wp.media

If you're still looking for this kind of answer, one way of figuring out what is firing is by entering this in your browser console and using the media modal: wp.media.frame.on('all', function(e) { ...
thumbson's user avatar
  • 201
5 votes
Accepted

'Add Media' button doesn't work when editor is initialized from javascript

The solution was to call wp_enqueue_media() along with wp_enqueue_editor().
Jesse Norell's user avatar
5 votes

Upload images from custom plugin using the media modal

Ah! The classic issue anyone that's cared about their users' experience has come to face. As per my experience, wp.media is the way to go. This is not my code, but it gets the job done. I've used ...
Jonathan Guerin's user avatar
4 votes

How to set additional parameter in wp.media?

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': { ...
webhead's user avatar
  • 41
3 votes
Accepted

admin_enqueue_scripts not working

If you remove that conditional in the first line of the enqueue function, your scripts should load. I can't see the broader context of why your function is written that way, but if you just copied it ...
tmdesigned's user avatar
  • 1,675
2 votes

Customizing the 3.5 "Add Media" popup (Backbone.js)

I had do adapt Backbone for a project of mine, so I might help to get you started. If you want to adapt the rendering of your Backbone Templates, you need to rewrite them, because there are no built ...
iantsch's user avatar
  • 814
2 votes

Trigger refresh for new media manager in 3.5

2019 update. I found a better solution that doesnt break the uploader: wp.media.frame.on('open', function() { if (wp.media.frame.content.get() !== null) { // this forces a ...
z1ad's user avatar
  • 46
2 votes

How to trigger a refresh in the media modal

You can checkout this link https://codex.wordpress.org/Javascript_Reference/wp.media jQuery(function($){ // Set all variables to be used in scope var frame, metaBox = $('#meta-box-id....
Rajilesh Panoli's user avatar
2 votes
Accepted

Keeping CSS model open after form submission

A combination of PHP and JS will do it. Have your page listen for the presence of gform_submit which Gravity Forms includes as a hidden field on all forms by default. if(!empty($_POST['gform_submit']...
WebElaine's user avatar
  • 9,664
2 votes
Accepted

Is it possible to hide media details sidebar when wp.media popup is being opened?

Ok, It's been so long since I posted this question I totally forgot about it. I finally used popup.on( 'open', function() {...}); to remove left modal sidebar. Here we go: popup.on( 'open', function()...
Daniel's user avatar
  • 193
2 votes
Accepted

Only displaying zip files with wp media

The zip files are in a subtype called application so you should try using: type: 'application/zip' A list of default allowed mime types is available from wp_get_mime_types.
Jami Gibbs's user avatar
2 votes

Restrict file types in the uploader of a wp.media frame

Just found a solution. It's a bit tricky, but works. As usually create media window, and save it to variable. var pdfPicker = wp.media({ title: 'Pick a PDF', button: { text: 'Use this ...
Никита Шишковский's user avatar
1 vote
Accepted

How to add extra EXIF data when images are uploaded?

Update: Edited code to make it work function proccess_to_all_image($file) { $file_path = $file['file']; $mime_type = $file['type']; $id = attachment_url_to_postid($file['url']); if (...
Kelvin Ngo's user avatar
1 vote
Accepted

Adding image to visual editor popup for shortcode with wp.media and wp.mce: changing image duplicates shortcode

I suspect that clicking the Select Image button on the popup is changing the underlying insertion point or selection in the main editor, but I can't for the life of me see how I can fix it. I'm ...
Sally CJ's user avatar
  • 39.9k
1 vote

overwrite wordpress gallery with custom gallery shortcode

At the top of the Gallery Shortcode Callback is a filter hook: post_gallery If any non-empty / non-null output is returned from this filter the shortcode will use that output instead of the default ...
Howdy_McGee's user avatar
  • 20.8k
1 vote
Accepted

Opening a JQuery modal window on click of a button with a JQuery plugin

First, make sure that your javascript files are loading correctly. Open Developer Tools while on the page (you can right click and select Inspect). Under the Elements tab, do a search for your ...
sMyles's user avatar
  • 2,866
1 vote
Accepted

trigger('change') not working

To use a custom control, you need a field with special attributes to be linked to the "publish" button. if you don't want to display this field, you can generate a hidden field like that : class ...
mmm's user avatar
  • 3,795
1 vote
Accepted

admin notice on Insert Media popup screen

I'm unaware of any hooks that tap in in the pop up, but there might be. If not, you could use some jQuery to put your message on the pop-up when Add Media is clicked. I was able to with the following:...
David Sword's user avatar
  • 3,357
1 vote

List of available events for wp.media

You can install the plugin WordPress Media Javascript Guide. It explains with screenshots and examples the must use method of the wp.media object.
Benoti's user avatar
  • 2,486
1 vote

Open the attachment details modal

Unfortunately the logic of the attachment details isn't made to be used standalone - it requires the grid that opens it. You can however use the get_media_item( attachment_id ) method to receive the ...
user63350's user avatar
  • 171
1 vote
Accepted

What's the best way to add taxonomy's image in 2017?

Here is something I use generally.. Please refer this link . and follow. This will help you definitel thanks
terminator's user avatar
1 vote

Is there a native wp.media way to detect who "opened" wp.media.frame

I think I got it , if (wp.media) { wp.media.view.Modal.prototype.on('open', function(data) { console.log(wp.media.frame.modal.clickedOpenerEl); }); } let me know if there is better ...
Benn's user avatar
  • 1,043
1 vote

How to trigger a refresh in the media modal

Try out: wp.media.editor.get(wpActiveEditor).views._views[".media-frame-content"][0].views._views[""][1].collection.props.set({ignore:(+(new Date()))}) Seems like there must be an easier way but ...
tru.d's user avatar
  • 186

Only top scored, non community-wiki answers of a minimum length are eligible