How can I point my wordpress media library to use a mounted drive as its source?

352 Views Asked by At

I've set up LAMP server and installed WordPress on my Raspberry Pi 4. When it is run locally, I can mount a NAS into the wp-content folder, and I can add media to my WordPress Media Library. However, once I switch the site address from the local IP to my domain name, the connection between my media library and the mounted NAS breaks, and I no longer have visibility in my media library of the content on my NAS.

I have thought about this for a minute, and the best I can come up with is, once I've changed my WordPress site address to my domain name, I should go into the wp-config file, and redefine where WordPress looks for the media library.

Am I on the right track? If so, can anyone point me to a section of the wp-config file where I could find the correct config to change? If not, I am open to any suggestions...

Thanks!

Edit: I realized the NAS content is showing up in the media library (I use this plugin to import the content), but whenever I try to watch a video, it says

Media error: Format(s) not supported or source(s) not found

I know the format is supported because I can play the content when the site hosted locally.

So I'm at a bit of a loss here...perhaps I need to remap the config file?

1

There are 1 best solutions below

0
On

Double-check that the reason for the video not playing is because of the domain change. You should be able to play your video in the browser using your-domain.tld/video.mp4 after changing your site to the domain name. If this works, then you need to update the domain in your WordPress install as you figured. You can do this by adding the following to wp-config.php

define( 'WP_HOME', 'http://your-domain.tld' );
define( 'WP_SITEURL', 'http://your-domain.tld' );

See: https://wordpress.org/support/article/changing-the-site-url/#edit-wp-config-php

Also, since you're running your site on your own server, you could install and use WP-CLI instead of a plugin. WP-CLI provides a wp media import command

$ wp media import /path-to-nas-media-folder

You can even set this up with cron, so media is added to your WordPress Media periodically.