WordPress 3.5 Media Manager – add a button

This block of code will add a button right next to the “Insert into post” one. When clicked, it will send selected images to WP editor, each wrapped inside your template HTML: var wpMediaFramePost = wp.media.view.MediaFrame.Post; wp.media.view.MediaFrame.Post = wpMediaFramePost.extend( { mainInsertToolbar: function( view ) { “use strict”; wpMediaFramePost.prototype.mainInsertToolbar.call(this, view); var controller = this; this.selectionStatusToolbar( view … Read more

ThickBox replacement

For what it’s worth, I have integrated the new media uploader in a plugin which allows the admin to select or upload media from the standard media dialog instead of having to copy/paste URLs, and it seems to work well. I posted an answer here that might be what you’re looking for. Tom McFarlin has … Read more

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.postbox’), // Your meta box id here addImgLink = metaBox.find(‘.upload-custom-img’), delImgLink = metaBox.find( ‘.delete-custom-img’), imgContainer = metaBox.find( ‘.custom-img-container’), imgIdInput = metaBox.find( ‘.custom-img-id’ ); // ADD IMAGE LINK addImgLink.on( ‘click’, function( event ){ event.preventDefault(); // If … Read more

Add filter function in media modal box

The wonderful world of Backbone.js and WP (of which I know barely anything). I think the problem is you are just calling the same default media.view, instead I believe you need to initialize a new one. For example: /** * Replace the media-toolbar with our own */ var myDrop = media.view.AttachmentsBrowser; media.view.AttachmentsBrowser = media.view.AttachmentsBrowser.extend({ createToolbar: … Read more

Using the WordPress 3.5 Media Uploader window as a modal popup

You can try the following script: var MEDIAmedia_library: function() { var formfield = null; var wireframe; $(‘body’).on(‘click’, ‘#click-event-selector’,function(e) { e.preventDefault(); if (wireframe) { wireframe.open(); return; } wireframe = wp.media.frames.wireframe = wp.media({ title: ‘Media Library Title’, button: { text: ‘Media Library Button Title’ }, multiple: false }); wireframe.on(‘select’, function() { attachment = wireframe.state().get(‘selection’).first().toJSON(); console.log(attachment); $(‘#input-field-selector’).val(attachment.url); }); … Read more

Trigger refresh for new media manager in 3.5

The correct way of refreshing the content of the frame, as found in the WP core, is as below: if(wp.media.frame.content.get()!==null){ wp.media.frame.content.get().collection.props.set({ignore: (+ new Date())}); wp.media.frame.content.get().options.selection.reset(); }else{ wp.media.frame.library.props.set({ignore: (+ new Date())}); } You should always check of the content is available, else refresh the library. Cheers!

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)