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!
📣 “ACF Chat Fridays”
— Advanced Custom Fields (@wp_acf) January 31, 2023
The ACF team holds their first open office hours this Friday! Come and talk ACF, and ask questions about building sites with the plugin.
We’d love to see you there!
📆 Friday 3rd Feb - 3pm UTC
👉 Register here - https://t.co/3UtvQbE4CU pic.twitter.com/oTwW9K1XQ0
© 2023 Advanced Custom Fields.
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 Cookie Policy. If you continue to use this site, you consent to our use of cookies.