Use a custom PHP function ( https://www.wpallimport.com/documentation/export/pass-data-through-php-functions/ ) on the content field to convert the image IDs to URLs. Example shortcode:
[vc_single_image image="177" img_size="full" add_caption="yes" alignment="center" style="vc_box_shadow_border"]
Example function:
function my_convert_images( $content ) {
if ( empty( $content ) ) return;
preg_match_all( '/image="(.*?)"/', $content, $matches );
if ( empty( $matches ) ) return $content;
foreach ( $matches[0] as $match ) {
$img_id = filter_var( $match, FILTER_SANITIZE_NUMBER_INT );
$img = wp_get_attachment_url( $img_id );
$content = str_replace( $match, 'image="' . $img . '"', $content );
}
return $content;
}
Example usage: https://d.pr/i/2smxLa.
Next, we'll use WP All Import's API ( http://www.wpallimport.com/documentation/developers/action-reference/ ) to import the image URLs and new IDs in the content.
Example code:
function my_update_content( $id, $xml, $u ) {
global $wpdb;
$post = get_post( $id );
$content = $post->post_content;
preg_match_all( '/image="(.*?)"/', $content, $matches );
if ( empty( $matches ) ) return;
foreach ( $matches[0] as $match ) {
$new_image_id = PMXI_API::upload_image( $id, $match, 'yes', false, true );
if ( ! empty( $new_image_id ) ) {
$content = str_replace( $match, 'image="' . $new_image_id . '"', $content );
}
}
$args = array( 'ID' => $id, 'post_content' => $content );
wp_update_post( $args );
}
add_action( 'pmxi_saved_post', 'my_update_content', 10, 3 );
@lukartel040978 this is only example code and it may need to be adjusted in different environments using different data. Please try using this alternative regex:
And replace the str_replace in the loop with this:
If that doesn't fix it, or if you need further help with this custom code, you'll need to work with a developer or ask for help here: https://stackoverflow.com/.