Add media attachment filter to custom wp.media frame

You need to make use of filterable property. To do that, you can extend the library and use that as a custom state. // Create state var myCustomState = wp.media.controller.Library.extend({ defaults : _.defaults({ id: ‘my-custom-state’, title: ‘Upload Image’, allowLocalEdits: true, displaySettings: true, filterable: ‘all’, // This is the property you need. Accepts ‘all’, ‘uploaded’, or … Read more

Add Additional File Info (jpeg compression & file size) settings to Edit Images Screen

You can try to use the attachment_submitbox_misc_actions filter to add more info to the box. Here is an example for the filesize part: add_action( ‘attachment_submitbox_misc_actions’, ‘custom_fileinfo_wpse_98608’ ); function custom_fileinfo_wpse_98608(){ global $post; $meta = wp_get_attachment_metadata( $post->ID ); $upload_dir = wp_upload_dir(); $filepath = $upload_dir[‘basedir’].”https://wordpress.stackexchange.com/”.$meta[‘file’]; $filesize = filesize($filepath); ?> <div class=”misc-pub-section”> <?php _e( ‘File Size:’ ); ?> <strong><?php … Read more

Set media metadata (i.e. “dimensions” field) on SVG file after extracting it with a filter

The wp_update_attachment_metadata filter fires every time you upload an image through media library (specifically every time wp_update_attachment_metadata function is being called). So when an svg file is uploaded we check if the file has the desired metadata, the width and height. If not, we generate the metadata as you did in your wp_get_attachment_image_src filter. Now … Read more

Edit image preview is not displayed

By default, wp-config.php might not have a closing tag ?> and this is acceptable and by design. The issue may arise from whitespace in some other .php file. In my case, I had whitespace after the closing tag of my functions.php file for my child theme. Once I removed that whitespace, the images are showing … Read more

Upload images from custom plugin using the media modal

Ah! The classic issue anyone that’s cared about their users’ experience has come to face. As per my experience, wp.media is the way to go. This is not my code, but it gets the job done. I’ve used it plenty. I’ll explain what it does, piece by piece: // Source: https://vedmant.com/using-wordpress-media-library-in-widgets-options/ jQuery(document).ready(function ($) { $(document).on(“click”, … Read more

Image uploading stuck on “crunching”

Ok so i’m on wordpress 3.8.1 and i was having this issue and i tried EVERY FIX from every post i could find on this problem of the image upload staying stuck on “crunching” or having it say “image data does not exist” So apparently if the image dimensions (e.g. 1920×1080) are bigger than what … Read more

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