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) { ...
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().
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 ...
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': {
...
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 ...
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 ...
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 ...
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....
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']...
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()...
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.
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 ...
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 (...
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 ...
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 ...
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 ...
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 ...
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:...
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.
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 ...
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
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 ...
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 ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
media-modal × 135media-library × 54
uploads × 37
media × 36
javascript × 17
jquery × 14
backbone × 14
plugin-development × 12
plugins × 9
attachments × 8
images × 7
twitter-bootstrap × 7
media-settings × 7
gallery × 6
php × 5
theme-development × 4
wp-admin × 4
custom-field × 3
filters × 3
css × 3
ajax × 3
videos × 3
thickbox × 3
wp-query × 2
customization × 2