Currently my videos are hosted within my wp installation. I want to move all videos to my new server.

Currently, my media url are as follows http://mysite.com/wp-content/uploads/video01.mp4

I am moving all videos to my central media server which will have this new url http://media.mysite.com/videos/video01.mp4

My site will continue to be hosted where it is right now. I will only move media files.

I was hoping Velvet Blues Update URLs will be up for the job but it does not find any url to update on my website.

Probably because I am using JW player on my site and JW player post video using shortcode and ID only on the post area.

[jwplayer mediaid="13441"]

No URL on the post. Maybe this is the reason why velvet blue is not picking up the URLS to update.

Having said that, is there a way to update all media urls in wordpress install from the media library as if it was added as external url?

Which database entries holds the media URL? I am guessing my last resort will be to run find and replace on my database.

Any suggestion will be highly appreciated.


4 Answers 4


is there a way to update all media urls in wordpress

I had a similar issue with my media files not having the correct file location after a Wordpress upgrade (somehow all the media links switched to a crazy incorrect directory), so I found Upload URL and Path Enabler which was able to rewrite all media URLs to a different path location where all my media was actually being stored.

Hope that helps someone else too!


I think you can create custom function to replace your old wp_attachment_url.

Assume you have same file name on your new media url, so you can add filter for jw player plugins only, something like this:

 if ( has_shortcode( get_the_content(), 'jw_player' ) ) { 
     function mynewmediaurl($wp_get_attachment_url){
$newmediadir = 'http://yourdomain/video/';
    $filename = basename($wp_get_attachment_url );
    $newurl = $newmediadir.$filename;
        return $newurl;
    add_filter('wp_get_attachment_url', 'mynewmediaurl');

you can add in your functions.php







Use WP-CLI's search-replace command to locate database entries with the old URL and replace them with the new one. You also can do a --dry-run to see how many entries are affected.

$ wp search-replace 'http://example.com/wp-content/uploads/' 'http://media.example.com/videos/' --dry-run
  • I have wasted many, many hours trying these "simple" wp cli "solutions". I have never once gotten the wp command to do anything besides spit up errors that I didn't understand and that I couldn't find explained anywhere online. There needs to be a working solution to this.
    – John Smith
    Commented Dec 31, 2023 at 2:34

Assuming that there are limited video in your site. you can replace URL by do following :

Expert your site database , Replace URL and import again. This is safe way to replace URL. You can do same thing using sql query also but that can cause problem sometime.

  • unfortunately there are around 1000 videos. editing manually is not something I am considering at this point unless there is no possibility of doing it using some kind of find and replace method Commented Nov 22, 2014 at 12:24
  • Right but find and replace can harm other URL.. Commented Nov 22, 2014 at 12:54
  • from my stand point and the nature of my website, I can live images not showing up than videos not playing. As long as videos load properly, I can manually hunt the other urls such as images to correct it manually over time. thanks Commented Nov 22, 2014 at 16:38
  • With some command line trickery, you can generate a list of all mp4 files in your wp-content/uploads folder, filter out the folder path in a text editor using search and replace, then pass the results line by line into WP CLI's search replace command. You don't need to do each one by hand 1 by 1
    – Tom J Nowell
    Commented Oct 26, 2015 at 14:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.