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’: { 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: … Read more

How to extend Media Library (WP 4.4)

It’s not a tab but you might be able to get started with an upload button. Check out pre-upload-ui and some actions that follow. Namely pre-plupload-upload-ui and post-upload-ui. This will add a couple buttons to the ‘Upload Files‘ tab and to ‘Media > Add New‘. BUTTONS add_action( ‘pre-plupload-upload-ui’, ‘wpse_20160202_pre_plupload_upload_ui’ ); add_action( ‘post-upload-ui’, ‘wpse_20160202_post_upload_ui’ ); function … Read more

Restrict the number of images to upload per post

I won’t go into the code specifics right now, because I am not sure if you need me to. You essentially need to modify the SWFUpload JavaScript settings array to set the file_upload_limit to 1. Unfortunately I don’t believe SWFUpload allows you to change that settings variable after it has been inited, because it has … Read more

Displaying oEmbed errors?

Not possible with current code. WP_oEmbed object goes extra mile (more like miles) to sanitize input so it is either html or boolean false. All errors with fetching are discarded on output, there are no filters in there and only error (hardcoded) it handles is 501 not implemented. Earliest you can mess with this is … Read more

Too much recursion error when chosing image from image library for two different meta boxes in one post

I think you’re running into a problem people mentioned in the comments to that story. Someone else posted about it here: http://www.theenglishguy.co.uk/2010/01/24/multiple-media-uploads-in-wordpress-functions-php/ Basically, the JavaScript from that site should be modified to be more like this: jQuery(document).ready(function() { var formlabel = 0; var old_send_to_editor = window.send_to_editor; var old_tb_remove = window.tb_remove; jQuery(‘.upload_image_button’).click(function(){ formlabel = jQuery(this).parent(); tb_show(”, … Read more

Using the media uploader in a custom plugin

The output code of widget’s form method is added to page once for every instance of the widget (included the “dummy” instance contained in the “Available widgets” panel), so in your case the javascript code that defines the window.send_to_editor function may appear more than once, and the last instance overwrites the previous ones. There are … Read more