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}”); }

How to restrict images in v3.5 Media Library modal to only those from a specific post id?

I am not sure is this what you are looking for. This code will “lock” uploads to show only “Uploaded to this post” in media panel add_action( ‘admin_footer-post-new.php’, ‘firmasite_mediapanel_lock_uploaded’ ); add_action( ‘admin_footer-post.php’, ‘firmasite_mediapanel_lock_uploaded’ ); function firmasite_mediapanel_lock_uploaded() { ?> <script type=”text/javascript”> jQuery(document).on(“DOMNodeInserted”, function(){ // Lock uploads to “Uploaded to this post” jQuery(‘select.attachment-filters [value=”uploaded”]’).attr( ‘selected’, true ).parent().trigger(‘change’); … Read more

How to get attachment id as soon as it is uploaded through media uploader in jquery?

You are close, you just need to hook into the add event instead of the reset event. (In case you did not know, these are standard events provided by Backbone collections. So familiarizing yourself with that will be helpful when developing things around stuff where WordPress employs Backbone.js.) So basically you’d modify your code like … Read more

Filter by post category in Media Library

You can use pre_get_posts to filter the query. So you can retrieve a category from query vars the retrieve the post with that category set the media query to include only post having that posts as parent To give an UI you can use restrict_manage_posts hook to output a category dropdown. add_action(‘pre_get_posts’, ‘my_filter_media_by_cat’); add_action( ‘restrict_manage_posts’, … Read more

Bind event on Media gallery elements WordPress

(function ($) { “use strict”; $(function () { var button = $(‘.upload-image’); button.click(function (e) { e.preventDefault(); // If the media frame already exists, reopen it. if (file_frame) { file_frame.open(); return; } var btn = $(this), media = wp.media; // Create the media frame. var file_frame = media.frames.file_frame = media({ title: jQuery(this).data(‘uploader_title’), button: { text: jQuery(this).data(‘uploader_button_text’) … Read more

sortable custom column in media library

You cannot do a sort on the attachment meta data specifically because it’s stored in a serialized string. Whilst WP_Query can sort on meta values it can’t sort on data that’s serialized. For example wp_get_attachment_metadata fetches and unserializes that for you inside the column callback, but MySQL queries can’t sort on that type of data. … Read more

WordPress 3.5 attachment_fields_to_edit and media_send_to_editor

So, there are some things which work differently (now). I. What you’ve noticed, when you click the checkbox WordPress sends an Ajax request to ‘wp_ajax_save_attachment_compat()’ with some form data, if your checkbox is checked, this information will be part of the form data. ‘wp_ajax_save_attachment_compat()’ checks for $_REQUEST[‘attachments’] and $_REQUEST[‘attachments’][$id] and will fail if it does … Read more

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