Filter for changing MediaElement.js Settings

Copy wp-includes/js/mediaelement/wp-mediaelement.js into your theme or plugin and make your modifications there. For example, I added some settings to force the use of native video controls on iOS & Android devices, like so: (function ($) { // add mime-type aliases to MediaElement plugin support mejs.plugins.silverlight[0].types.push(‘video/x-ms-wmv’); mejs.plugins.silverlight[0].types.push(‘audio/x-ms-wma’); $(function () { var settings = { // Put … Read more

Image upload callback in new 3.5 media

There is a FileUploaded event being fired in wp-includes/js/plupload/wp-plupload.js. Alternatively (and propably the better way) you may want extend wp.Uploader with your own success callback . (function($){ $.extend( wp.Uploader.prototype, { success : function( file_attachment ){ console.log( file_attachment ); } }); })(jQuery);

Stop WordPress from reserving slugs for media items?

Thank you for the response everyone. I played around with macemmek’s solution and I think it led me to an even better solution: add_filter( ‘wp_unique_post_slug_is_bad_attachment_slug’, ‘__return_true’ ); That is all that is needed. This will automatically ‘skip’ the default assigned slug on any attachment. So an attachment that might normally get the slug “services” will … Read more

Proper way to add a button to the top menu of the media library?

So, this is the only way I’ve found so far and it’s ugly, however WordPress offers no means of modifying this through filters that I can find in core. I present, the hacky “do-it-through-Javascript” method: add_action( ‘load-upload.php’, function(){ $js = <<<JAVASCRIPT jQuery(document).ready(function($){ setTimeout(function() { $(‘.wp-filter .button:last’ ).after($(‘<button class=”button”>Hi</button>’)); }, 1000); }); JAVASCRIPT; add_filter( ‘admin_footer’, function() … Read more

Display attachments by ID in a wp.media frame

You can always filter on the client side: var query = wp.media.query(); query.filterWithIds = function(ids) { return _(this.models.filter(function(c) { return _.contains(ids, c.id); })); }; var res = query.filterWithIds([6,87]); // change these to your IDs res.each(function(v){ console.log( v.toJSON() ); }); Disclaimer: found the beautiful filterWithIds function in this SO question.

Remote upload file to server B

Try adding die(‘message’); and use that to debug where it fails. Also try and use ftp://external-server.com as opposed to just external-server.com. Also make sure you use your FTP password. And try it on active mode as opposed to passive mode. When I was trying to upload by FTP that’s what I had to do. Also … Read more

WordPress Media Manager 3.5 – default link to

You can do what you want by overriding appropriate Backbone view, which is responsible for rendering attachments display settings form. plugin.php add_action( ‘load-post.php’, ‘wpse8170_media_popup_init’ ); add_action( ‘load-post-new.php’, ‘wpse8170_media_popup_init’ ); function wpse8170_media_popup_init() { wp_enqueue_script( ‘wpse8170-media-manager’, plugins_url( ‘/js/media.js’, __FILE__ ), array( ‘media-editor’ ) ); } media.js (function() { var _AttachmentDisplay = wp.media.view.Settings.AttachmentDisplay; wp.media.view.Settings.AttachmentDisplay = _AttachmentDisplay.extend({ render: function() … Read more

error code: 523