Title: mb0wordpress's Replies | WordPress.org

---

# mb0wordpress

  [  ](https://wordpress.org/support/users/mb0wordpress/)

 *   [Profile](https://wordpress.org/support/users/mb0wordpress/)
 *   [Topics Started](https://wordpress.org/support/users/mb0wordpress/topics/)
 *   [Replies Created](https://wordpress.org/support/users/mb0wordpress/replies/)
 *   [Reviews Written](https://wordpress.org/support/users/mb0wordpress/reviews/)
 *   [Topics Replied To](https://wordpress.org/support/users/mb0wordpress/replied-to/)
 *   [Engagements](https://wordpress.org/support/users/mb0wordpress/engagements/)
 *   [Favorites](https://wordpress.org/support/users/mb0wordpress/favorites/)

 Search replies:

## Forum Replies Created

Viewing 1 replies (of 1 total)

 *   Forum: [Developing with WordPress](https://wordpress.org/support/forum/wp-advanced/)
   
   In reply to: [get_post_gallery_images()](https://wordpress.org/support/topic/get_post_gallery_images/)
 *  Thread Starter [mb0wordpress](https://wordpress.org/support/users/mb0wordpress/)
 * (@mb0wordpress)
 * [5 years, 10 months ago](https://wordpress.org/support/topic/get_post_gallery_images/#post-13128438)
 * I knew what bcworkz said about it not working with the block editor galleries(
   I’ve had problems with this function before), so now Im just confused as to why
   it worked when I used it in v 5.1.6.
 * Anyway, with a combination of the two answers I threw together this which seems
   to work fine. The theme I’m developing is for myself, so I know I can always 
   guarantee that the first gallery will the be one I need (and I know it will always
   be there), which is why I was fine hardcoding it.
 *     ```
       $postBlocks = parse_blocks($post->post_content);
       $firstGalleryIds = $postBlocks[0]["attrs"]["ids"];
       $previewImages = [];
   
       foreach ( $firstGalleryIds as $imgSource ) {
   
       	$previewImages[] = wp_get_attachment_image_src( $imgSource, $size = 'large' )[0];
   
       }
       ```
   

Viewing 1 replies (of 1 total)