How to display .ico files in the media library

Update: It looks like this will be supported in 5.0+. See ticket #43458 The default This is how the favicon (.ico) files show up in the Media Grid view: This is the corresponding part of the micro template: <# } else if ( ‘image’ === data.type && data.sizes ) { #> <div class=”centered”> <img src=”https://wordpress.stackexchange.com/questions/177981/{{ … Read more

How do I select an image from Media Library in my plugin?

You should use wp.media to use the WordPress Media Manager dialog. First, you need to enqueue the scritps: // As you are dealing with plugin settings, // I assume you are in admin side add_action( ‘admin_enqueue_scripts’, ‘load_wp_media_files’ ); function load_wp_media_files( $page ) { // change to the $page where you want to enqueue the script … Read more

Get All Images in Media Gallery?

$query_images_args = array( ‘post_type’ => ‘attachment’, ‘post_mime_type’ => ‘image’, ‘post_status’ => ‘inherit’, ‘posts_per_page’ => – 1, ); $query_images = new WP_Query( $query_images_args ); $images = array(); foreach ( $query_images->posts as $image ) { $images[] = wp_get_attachment_url( $image->ID ); } All the images url are now in $images;

Change the default-view of Media Library in 3.5?

There were two minor mistakes in my previous answer: I forgot to trigger the change event for the parent. I called the function on every AJAX call, making other selections impossible. Here is the fixed code: <?php /** * Plugin Name: Pre-select post specific attachments */ add_action( ‘admin_footer-post-new.php’, ‘wpse_76048_script’ ); add_action( ‘admin_footer-post.php’, ‘wpse_76048_script’ ); function … Read more