Hello,
My custom type have and image as custom field. I'm developing on localhost so if I use absolute path, then path starting with localhost stays there with image. All the files in media library have their domain changed when I upload it to live server, but not custom field of toolset.
I wanted to use relative paths, but according to other tickets you don't support it.
Could you please help me solve this issue? How to force domain change on custom fields?
Best regards,
Ferdinand
Hi, a good site migration tool will update the image URLs in your custom fields during migration of the database (DB). I use Duplicator Pro, but there are other 3rd-party plugins available that will help facilitate text replacement in the DB during migration. Other than that, you have the option to write your own DB migration script, but I don't recommend that unless you're comfortable writing SQL queries to manipulate the DB directly. WordPress's documentation also has some migration information you may find useful: https://codex.wordpress.org/Moving_WordPress
Here's some code you can throw into your functions.php file to change the URLs output by 'raw' to be site relative.
/* Toolset Views: If the feature image output is "raw" convert the URLs emitted to a site relative path */
add_filter( 'wpv-post-featured-image', 'site_relative_featured_image' );
function site_relative_featured_image( $in ) {
if (substr($in, 0, 4) === "http") {
$in_arr = explode("/", $in);
$in_arr = array_slice($in_arr, 3);
$out = "/" . implode("/", $in_arr);
return $out;
} else {
return $in;
}
}