Re: WP-minify and new version of Buddypress
Here is a way I have found to make avatar uploads work while still using a CDN. I’m using S3/Cloudfront but it shouldn’t make a difference.
The avatars, once accepted have a filename that always ends in either ‘bpfull.jpg’ or ‘bpthumb.jpg’
When an avatar is being dealt with by the upload/cropping process, the images used are not given these names.
If uploaded at registration time they are stored in an avatars/signups/ folder
If uploaded once a user is a registered member, they will always have the file size at the end of the filename (e.g. 200×200.jpg)
Using this info, I did the following:
in my custom file list, I added the following:
`wp-content/uploads/avatars/*bpfull.*
wp-content/uploads/avatars/*bpthumb.*`
in my rejected files list, I added the following:
`/wp-content/uploads/avatars/signups/*
/wp-content/uploads/avatars/*/*x*.*`
I’m not too happy with the rules for rejection, it seems like there might be a danger of having a file named xxxbpfull.jpg being rejected and sourced locally, but given that any files that don’t contain an x will be sourced from my CDN I am pretty happy with this level of fudgery. In any case, this does mean that the files required to process the cropping will be sourced locally and therefore avatar uploads will work.
The last thing to do is to set the autoupload time to something reasonable – I have set it to 10 minutes at the moment mainly so I can check that this all works okay, and also to see how much the autoupload script hammers the server. If it were possible it would be nice to add a hook at the end of the avatar cropping function that calls an image upload to the CDN for the file that has been created, but waiting 10 minutes to an hour for an avatar is not so bad.
Hopefully this is helpful, and if anybody has better rules for the rejected file list I would be super happy to see them.