I am busy with a loop to return all media in the medialibrary in objects.
I figured out how to get the images ( with wp_get_attachment_image('$mediaID')
where the $mediaID is the id of the image )
But I want to loop all media, not just the images, is there a function that I can use for video's and audio that is also from the medialibrary.
I tried get_attached_media
but this will only work if the media is actually attached and I want to loop all media.
Is there a way to do this and to get it as objects?
Thanks in advance.
P.S.
The code I am using is:
<?php
$query_images_args = array(
'post_type' => 'attachment', 'post_mime_type' =>'', 'post_status' => 'inherit', 'posts_per_page' => -1,
);
$query_images = new WP_Query( $query_images_args );
foreach ( $query_images->posts as $media) {
//save the url in a variable to test with
$media_url = wp_get_attachment_url( $media->ID );
$mediaID = $media->ID;
echo wp_get_attachment_image( $mediaID );
}
?>
P.P.S. I do this because I want to show the media in some sort of library on the front end. Later there will be categories like 'video', 'audio' and 'img'
$media
not already an object?