Ivijan Stefan Stipić
Ivijan Stefan Stipić

Reputation: 6668

How to change image path in WordPress to subdomain in PHP

I have one big site in WordPress that has many images. I want to speed up site using subdomain to browser load images from subdomain.

I want to point subdomain root to wp-content/uploads/ and instead to load from:

www.example.com/wp-content/uploads/2015/03/example.jpg

I want to load from:

www.media.example.com/2015/03/example.jpg

Where in PHP I can change that?

Upvotes: 1

Views: 951

Answers (2)

Suhimi Nain
Suhimi Nain

Reputation: 26

No need using PHP,

your just need to run this this SQL Query in phpmyadmin.

UPDATE wp_posts SET post_content = REPLACE(post_content,'http://www.yourdomain.com/wp-content/uploads/','http://images.yourdomain.com/')

For more information you can refer to this link.

http://www.oxhow.com/host-images-wordpress-blog-subdomain-better-speed/

Upvotes: 1

Sibin Grasic
Sibin Grasic

Reputation: 714

Go to wp-admin/options.php

There you have two options:

upload_path

upload_url_path

Change both and you're all set

Upvotes: 1

Related Questions