Uploads/Media Best Practice


#1

I’ve looked and searched here for any best practice for handling and serving media/uploads/images; staying organised and in sync.

I’m using a digital ocean setup and have the uploads content served directly from there.

Ultimately I know media/content should be uploaded to the live site, with copies pulled into development when its necessary to do so. But initial setups/builds always take place locally until theres something worth pushing live/staging.

I use wp-db-sync to keep the database up-to-date in either direction and this works wonderfully.

For uploading/downloading images scp is used.

Is this whats most common or do people make use of CDNs s3 or some other cloud solution?

Any pointers or suggestions welcome, apologies if my question is not direct enough.


#2

I personally find this playbook handy by @louim. It uses rsync which is a lot more efficient than scp. It only copies media when it’s needed.

Of course having a CDN would be ideal, but in some projects the budget/time doesn’t allow for it

Here’s the full post: Pushing or pulling uploads with Trellis


#3

This is a free plugin but the premium version it’s ripping off has a Media Files add-on. It’ll do a media transfer while syncing the DB.


#4

Thanks @Simeon the ‘legit’ version is on my radar and I may well fork out in the future once the number of wp sites maintained/built justifies it.


#5

For us, the best practice is not keeping uploads on the Wordpress instance at all. Everything goes to S3. Images are served through Imgix, which performs all the image operations such as scaling and cropping on the fly.

I wrote a plugin to manage all of this:

You can use via composer ilab/ilab-media-tools


#6

Thanks for linking this, looks like a fantastic solution. Will be using this in the next build :grinning:


#7

Hi @Jon. Gave your plugin a whirl as it solves a key need here. added via composer and went to activate to find it won’t with a fatal error below. On php7, sage9.
atal error: Cannot redeclare render_view() (previously declared in /srv/www/[domain].com/current/web/app/plugins/wp-views/embedded/inc/wpv-api.php:147) in /srv/www/[domain].com/current/web/app/plugins/ilab-media-tools/helpers/ilab-media-tool-view.php on line 77
Call Stack

Time Memory Function Location

1 0.0010 473968 {main}( ) …/plugins.php:0
2 1.8409 57162512 plugin_sandbox_scrape( ) …/plugins.php:164
3 1.8416 57176136 include( ‘/srv/www/[domain].com/current/web/app/plugins/ilab-media-tools/ilab-media-tools.php’ ) …/plugin.php:1882


#8

You have two plugins with the same function name. They should either be prefixing their function name with a unique prefix or using PHP namespaces. You should probably let both of them know their plugin code is causing fatal errors.


#9

Thanks for the plugin Jon! I’ll be giving it a try.


#10

That’s what you get for using Types :wink:


#11

I just posted 1.4.7 which fixes the issue.

Thanks!


#12

Thanks man! I see all y’all ACF fan-boys :slight_smile:


#13

#14

Great plugin @Jon . I’m slowly stripping out Types for ACF and dropped S3 Offload in favor of Media Cloud with imgix. Top notch work.