Calling WP Gallery Uploader/Selector From Metabox

Figured out the answer to the question. file_frame.on(‘open’, function() { var selection = file_frame.state().get(‘selection’); var library = file_frame.state(‘gallery-edit’).get(‘library’); var ids = jQuery(‘#fg_perm_metadata’).val(); if (ids) { idsArray = ids.split(‘,’); idsArray.forEach(function(id) { attachment = wp.media.attachment(id); attachment.fetch(); selection.add( attachment ? [ attachment ] : [] ); }); file_frame.setState(‘gallery-edit’); idsArray.forEach(function(id) { attachment = wp.media.attachment(id); attachment.fetch(); library.add( attachment ? [ … Read more

How to retrieve a value from an input field in a media view template

After digging through the media modal code, I came up with the answer to my question: wp.media.controller.Custom = wp.media.controller.State.extend({ initialize: function(){ this.props = new Backbone.Model(); }, // called when the toolbar button is clicked customAction: function( controller ){ // get the value of a media view template form field using // this.props.get(‘key’), where ‘key’ is … Read more

How do I create a custom add media button modal?

You can inspire from this tutorial here: http://www.sitepoint.com/adding-a-media-button-to-the-content-editor/ For videos you can change the library type to ‘video’: function open_media_window() { var window = wp.media({ title: ‘Insert a media’, library: {type: ‘video’}, multiple: false, button: {text: ‘Insert’} }); } Hope this helps.

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() { jQuery( ‘.media-frame-menu’ ).remove(); jQuery( ‘.media-frame-router, .media-frame-title, .media-frame-content, .media-frame-toolbar’ ).css({‘left’: 0}); }); That’s it 🙂 EDIT I managed to hide right hand … Read more

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 from a tutorial or something, you don’t need it here. Try: <?php function sunset_load_admin_scripts(){ wp_enqueue_media(); wp_register_script(‘sunset-admin-script’,get_template_directory_uri() .’/js/news_admin.js’, array(‘jquery’), … Read more

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