Get all image in media Gallery with alt/title?

Is there a way to fetch the ALT/TITLE of ALL images in the media gallery?

I think this would be an easy way for a website to have a Pictures page that just pulls all of the images from the media gallery, granted it would only be necessary in certain scenarios.

I don't need instructions on how to create a Pictures page, just how to pull all of the image URLs. Thanks!

Topic attachment-fields-to-edit attachments images plugins Wordpress

Category Web


<?php

/*
* Template Name: Gallery Page
*/

$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 );

?>
<?php get_header();?>
<div class="main">
    <div class="row">
        <?php foreach ( $query_images->posts as $image ) {?>
            <div class="col-md-3">
                <?php echo wp_get_attachment_image( $image->ID,'thumbnail' );?>
            </div>
        <?php }?>

    </div>
</div>
<?php get_footer();?>

$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_image( $image->ID,'thumbnail' );
}

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.