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

Uploading media with the REST API

This is not possible via the API; you need to fetch the image yourself, and send the data to the API yourself. Blockquote – This quotes Ryan on the GitHub–issue mentioned in @Dan (deleted) answer. How to side load images Note that the media_sideload_image() return value can be an instance of \WP_Error as well. You … Read more

How to add a custom field to the media screen (image/gallery)?

Here is the working code (working fine for me), did you tried this? Just add to theme ‘functions.php’ and change the custom field names as needed. //function to add custom media field function custom_media_add_media_custom_field( $form_fields, $post ) { $field_value = get_post_meta( $post->ID, ‘custom_media_style’, true ); $form_fields[‘custom_media_style’] = array( ‘value’ => $field_value ? $field_value : ”, … Read more

Media library to list images only user uploaded

This works for me in order to list the items uploaded by a user on the media library. function users_my_media_only( $wp_query ) { if ( false !== strpos( $_SERVER[ ‘REQUEST_URI’ ], ‘/wp-admin/upload.php’ ) ) { $current_user = wp_get_current_user(); $current_user = $current_user->ID; if ( ! current_user_can( ‘manage_options’ ) ) { global $current_user; $wp_query->set( ‘author’, $current_user->id ); … Read more

Adding Category/Tag/Taxonomy Support to Images/Media

Here’s how I recently added a custom taxonomy to the media library as a sortable column: // Add a new column add_filter(‘manage_media_columns’, ‘add_topic_column’); function add_topic_column($posts_columns) { $posts_columns[‘att_topic’] = _x(‘Topic’, ‘column name’); return $posts_columns; } // Register the column as sortable function topic_column_register_sortable( $columns ) { $columns[‘att_topic’] = ‘att_topic’; return $columns; } add_filter( ‘manage_upload_sortable_columns’, ‘topic_column_register_sortable’ ); … Read more

Display Media Uploader in Own Plugin on WordPress 3.5

Only Uploader below a example code, works only on post edit page. If you will use also on other page, then include the function wp_enqueue_media(), see the next headline. jQuery(document).ready(function($) { var _custom_media = true, _orig_send_attachment = wp.media.editor.send.attachment; $(‘.stag-metabox-table .button’).click(function(e) { var send_attachment_bkp = wp.media.editor.send.attachment; var button = $(this); var id = button.attr(‘id’).replace(‘_button’, ”); _custom_media … Read more

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