A
A
Andrew_ST2017-03-18 10:48:56
WordPress
Andrew_ST, 2017-03-18 10:48:56

How to transfer images to a subdomain in Wordpress?

Hello. The question is, there is an online store Wordpress+Woocomerce.
I want to make images loaded from a subdomain of my site.
Now the pictures are loaded with Photon from JetPack, but the validator swears at these pictures, because ALT tags are not assigned to them.
Previously, in the Wordpress settings, you could change the address of the images. Now there is no such possibility.
I would like to do it without plugins.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
E
EvgenyMorozov, 2017-03-18
@Andrew_ST

An option if everything is already set up and you need to "transfer" the statics to a subdomain.
Add static.example.com to nginx

server { 
server_name example.com static.example.com;
}

Add cname static.example.com 12.34.56.78 (server ip) to DNS -- after updating DNS, the site should ping static.example.com.
Next
In the WordPress admin panel Settings->Media Files, set the Full URL path to the files to http://static.example.com/wp-content/uploads. Now new pictures will be added with this path.
Replace all image paths in the database using wp-cli with
http://static.example.com/wp-content/uploads
wp search-replace 'http://example.com/wp-content/uploads' 'http://static.example.com/wp-content/uploads'

In wp-config.php
define('COOKIE_DOMAIN', 'example.com' );
define('WP_PLUGIN_URL', 'http://static.example.com/wp-content/plugins');

If everything worked out, then now pictures, CSS & JS plugins are given from static.example.com, while nothing is transferred anywhere and lies in the usual place.

K
Karen Mnatsakanyan, 2017-03-18
@karjan

I think you will find it here

D
DimDim7778, 2017-08-16
@DimDim7778

here is a plugin for that:
https://wordpress.org/plugins/wp-original-media-path/

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question