El siguiente código nos muestra dos imágenes aleatorias del media library:
$media_query = new WP_Query(
array(
'post_type' => 'attachment',
'post_status' => 'inherit',
'posts_per_page' => 2,
'orderby'=>'rand'
)
);
foreach ($media_query->posts as $post) {
echo wp_get_attachment_image($post->ID,'thumbnail');
}