Home › Forums › Add-ons › Gallery Field › How to extract the serialized array › Reply To: How to extract the serialized array
If you’re not inside WP then it will be extremely difficult to get what you’re looking for. It’s going to take some additional queries.
ACF stores only the attachment ID in a serialized array. You will first need to unserialize the array and then you will need to do queries to get the image URL.
If I was doing this inside of WP I would do something like this.
$image_array = maybe_unserialize(get_post_meta($post_id, 'gallery_field', true));
$count = count($image_array);
for ($i=0; $i<$count; $i++) {
$image = wp_get_attachment_src($image_array[$i], 'full');
$image_src = $image[0];
}
I am not familiar with exactly how you’d do that with SQL.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.