$conf, $runtime; function_exists('chdir') AND chdir(APP_PATH); $r = 'mysql' == $conf['cache']['type'] ? website_set('runtime', $runtime) : cache_set('runtime', $runtime); } function runtime_truncate() { global $conf; 'mysql' == $conf['cache']['type'] ? website_set('runtime', '') : cache_delete('runtime'); } register_shutdown_function('runtime_save'); ?>urls - WPALLIMPORT Exporting images from repeater field|Programmer puzzle solving
最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

urls - WPALLIMPORT Exporting images from repeater field

matteradmin7PV0评论
Closed. This question is off-topic. It is not currently accepting answers.

Your question should be specific to WordPress. Generic PHP/JS/SQL/HTML/CSS questions might be better asked at Stack Overflow or another appropriate Stack Exchange network site. Third-party plugins and themes are off-topic for this site; they are better asked about at their developers' support routes.

Closed 6 years ago.

Improve this question

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

s:267:"a:9:{s:10:"sm-field-0";s:4:"1228";s:10:"sm-field-1";s:4:"1229";s:10:"sm-field-2";s:4:"1230";s:10:"sm-field-3";s:4:"1231";s:10:"sm-field-4";s:4:"1232";s:10:"sm-field-5";s:4:"1233";s:10:"sm-field-6";s:4:"1234";s:10:"sm-field-7";s:4:"1235";s:10:"sm-field-8";s:4:"1236";}";

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

Closed. This question is off-topic. It is not currently accepting answers.

Your question should be specific to WordPress. Generic PHP/JS/SQL/HTML/CSS questions might be better asked at Stack Overflow or another appropriate Stack Exchange network site. Third-party plugins and themes are off-topic for this site; they are better asked about at their developers' support routes.

Closed 6 years ago.

Improve this question

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

s:267:"a:9:{s:10:"sm-field-0";s:4:"1228";s:10:"sm-field-1";s:4:"1229";s:10:"sm-field-2";s:4:"1230";s:10:"sm-field-3";s:4:"1231";s:10:"sm-field-4";s:4:"1232";s:10:"sm-field-5";s:4:"1233";s:10:"sm-field-6";s:4:"1234";s:10:"sm-field-7";s:4:"1235";s:10:"sm-field-8";s:4:"1236";}";

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

Share Improve this question asked Feb 18, 2019 at 13:14 Alex TrainorAlex Trainor 32 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

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.

Post a comment

comment list (0)

  1. No comments so far