I'm displaying a gallery image but I also want display the caption for image. I can get the info that we insert when us upload a image in WordPress Dashboard like "Title/Caption/ALT/Description". I want get anyone and display.
<?php
$gallery = get_post_gallery_images( $post );
foreach( $gallery as $image_url ) :
?>
<div class="item" style="background-image: url('<?php echo $image_url ?>'); background-size: cover">
<div class="caption">
<!-- Here I want display the Title/Caption/ALT/Description of image -->
<h2><?php echo $image_url->"DESCRIPTION/TITLE/ALT"; ?> </h2>
</div>
</div>
Reading at the docs of get_post_gallery_images I didn't find a solution for my issue.
I also found this answer but I don't know if it works and I've erros to implement in my code.
Anyway, how can I solve this?