What is the best practice for renaming WordPress media files?

As Rarst has explained, you can’t really directly edit your database, or you’ll risk killing the serialized data. Your options are thus to: delete the file and re-upload it with its new name (obviously has the downside of having to reinsert it everywhere it was being used), or to use one of the media renaming … Read more

display image size in media library screen

Code based on Custom Sortable Columns add_filter(‘manage_upload_columns’, ‘size_column_register’); function size_column_register($columns) { $columns[‘dimensions’] = ‘Dimensions’; return $columns; } add_action(‘manage_media_custom_column’, ‘size_column_display’, 10, 2); function size_column_display($column_name, $post_id) { if( ‘dimensions’ != $column_name || !wp_attachment_is_image($post_id)) return; list($url, $width, $height) = wp_get_attachment_image_src($post_id, ‘full’); echo esc_html(“{$width}×{$height}”); }

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

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

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

WordPress Image Editor not working – conflict?

I have actually managed to resolve my own problem. For anyone else that might ever read this the problem which caused this was that my functions.php file had a closing ?> at the very end. For whatever reason this is what cause the issue and by removing this last line it was working again.

Rendering the uploaded file in a wp.media object

I presume you’ve fixed this already but (in a blatant attempt to snaffle the bounty and) as mentioned in the comments there’s a simple fix, in your myplugin_meta_box_callback() function change the line $mime_types = array( ‘application/pdf’ ); to $mime_types=”application/pdf”; The library.type option to wp.media expects a string (which can be comma-separated with additional types) not … Read more

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