WPALLIMPORT Exporting images from repeater field

I am getting this ouput when I export the custom field image,


I can add a function or php to covert this to URLS? but I have no idea. Can anyone help?

Answers 1

  • That is a serialized string, actually it's a serialized string of a serialized string, which is very odd. You need to convert it to an array and then get the image URLs from the IDs that it is returning.

    Lets say $str is the variable that contains that string, here's how you would get the image URLs from those attachment IDs. FYI I put the second unserialize call inside an if statement so it won't break if your value ever becomes just a single serialized string

    function parseUrlsFromSerializedIds($str) {
        $arr = unserialize($str);
        if (is_serialized($arr)) {
            $arr = unserialize($arr);
        $results = [];
        foreach ($arr as $imageID) {
            $url = wp_get_attachment_url($imageID);
            $results[] = $url;
        return implode(',', $results);

    Inside that foreach you'll want to do something with the URL. I'm not sure what format you're trying to return them all in so I left it alone.

Related Questions