How to rename an image attachment filename using php

Let’s go and see. If I take arbitrary attachment in my dev install and dump its post object and custom fields I get the following: object WP_Post (24) { public ID -> integer 1687 public post_author -> string (1) “1” public post_date -> string (19) “2013-09-18 14:37:07” public post_date_gmt -> string (19) “2013-09-18 21:37:07” public … Read more

Modify Custom Field in Media Library using JavaScript

One way to do it (which is probably evil) is to select the control by adding a block of javascript using the tr field of $form_fields: function set_image_data( $form_fields, $post ) { $form_fields[‘text_color’] = array( ‘label’ => ‘Text Color’, ‘input’ => ‘text’, ‘value’ => get_post_meta( $post->ID, ‘_text_color’, true ) ); ob_start(); ?> <script type=”text/javascript”> jQuery(‘[name$=”[text_color]”]’).myColorPicker(); … Read more

Ignore a filter on the media library

You can use is_admin() in conjunction with the admin global variable $pagenow to make sure you’re not on either the upload or media page: function remove_images( $where ) { global $wpdb, $pagenow; if( is_admin() && in_array( $pagenow, array( ‘upload.php’, ‘media-upload.php’ ) ) { return $where } $where .= ” AND {$wpdb->posts}.post_mime_type NOT LIKE ‘image/%'”; return … Read more

Is there a way to specify the tab to display when the Media Uploader is displayed?

The following code will select a custom tab labeled Your Tab Name when launching the Media Library for the first time. add_action( ‘admin_footer-post-new.php’, ‘wpse_default_media_library_tab’ ); add_action( ‘admin_footer-post.php’, ‘wpse_default_media_library_tab’ ); function wpse_default_media_library_tab() { ?> <script type=”text/javascript”> var my_tab_has_been_activated = 0; (function($) { $(document).ready( function() { // http://wordpress-hackers.1065353.n5.nabble.com/JavaScript-events-on-media-popup-td42941.html $(document.body).on( ‘click’, ‘.insert-media’, function( event ) { if ( … Read more

Remove the columns in media library

The hook for these columns is manage_media_columns. So just filter the columns here: add_filter( ‘manage_media_columns’, ‘wpse_77687_remove_media_columns’ ); function wpse_77687_remove_media_columns( $columns ) { unset( $columns[‘author’] ); unset( $columns[‘comments’] ); return $columns; }

How can I attach images to a post from the media library?

This is not something that is currently supported in WordPress. There’s some discussion about it here: http://core.trac.wordpress.org/ticket/6820 One plugin which does enable this functionality is: http://skyphe.org/code/wordpress/file-gallery/ This plugin does a few extra things, but one option it provides is that after clicking “upload/insert” and going to the media library tab, you can tick check boxes … Read more

Saving Custom Field in Attachment Window in WordPress 3.5

I wanted to be able to add author information to my attachments and merged this code: http://www.billerickson.net/wordpress-add-custom-fields-media-gallery/ with the one you refer to. I Got it to work fully in the modal window via AJAX. The modified code is as follows: /** * Add Author Name and URL fields to media uploader * * @param … Read more

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