How to get Images post ID (to use with Enfold gallery)

I made a blog with posts, and i would like to show the attached images in a post in a gallery in the single.php.

But I get this error when opening a post.. A critical error has occurred on this site.

Here i get all the images and their ids

functions.php:

function prefix_get_img_ids($  atts) {     global $  post;     $  images = (array) get_post_meta($  post->ID, 'wpcf-listing-pictures', false); // cast to array in case there is only one item     $  ids = array();     global $  wpdb;     foreach($  images as $  img) {         $  query = "SELECT ID FROM {$  wpdb->posts} WHERE guid='$  img'";         $  id = $  wpdb->get_var($  query);         $  ids[] = $  id;     }     return implode(",",$  ids); } add_shortcode("get-image-ids", "prefix_get_img_ids"); 

Here i use the shortcode with the shortcode in the ‘ids’ tag.

Single.php:

<?php      echo do_shortcode("[av_gallery ids="[get-image-ids]" style='big_thumb' preview_size='portfolio' crop_big_preview_thumbnail='avia-gallery-big-crop-thumb' thumb_size='portfolio' columns='5' imagelink='lightbox' lazyload='avia_lazyload']");  ?> 

Anybody know a way to solve this issue? Thanks