Sharing a common set of image files for media library, across all sites within multisite

In mutisite, the uploads directory structure looks like this:

/wp-content/uploads/sites/1/
                         /2/
                         /3/

Each number is the id of the site within the network of sites.

My plugin installs several image files into each site’s respective upload directory then calls wp_insert_attachment to get the images into each site’s media library. I have that figured out.

What is bothering me is that if I have 1,000 sites and 100 canned images, that means I will have 100,000 image files strewn across all those sub-directories – seemingly needless duplication.

I’m thinking of creating a base directory in /wp-content/uploads/ and then putting a symbolic link into each of the sites’ upload sub-directories, pointing back to that base directory. Then, run wp_insert_attachment using the symbolic link / filenames.

The users are prevented from editing or deleting these image files based on my permission schema.

Do you think this idea will be robust, or if not are there any alternatives?

0

Leave a Comment