Issues getting image ids from Gutenberg gallery block
-
We have built a custom gallery that uses the gallery block but our client recently pointed us that these galleries would not display anymore.
A quick check shows us that we are not able to access the ids of the gallery’s images anymore.Here is how we coded things on our end:
function get_img_gallery( $post ) { if ( has_block( 'gallery', $post->post_content ) ) { $els = parse_blocks( $post->post_content ); foreach ( $els as $el ) { if ( $el['blockName'] == 'core/gallery' ) : $gallery_imgs_ids = $el['attrs']['ids']; return $gallery_imgs_ids; endif; } } }We are getting an error “Undefined index: ids” so it seems that “ids” are no longer passed in the “attrs” array? (You can check that on the provided link, right before the Google Map integration near the footer of the page)
Might it be that we missed an update regarding how these attributes work? How can we fix that?
Thanks!
The page I need help with: [log in to see the link]
The topic ‘Issues getting image ids from Gutenberg gallery block’ is closed to new replies.