让Mingle Forum上传的图像放置在单独的目录 Let Mingle Forum upload images to isolated directories

2013-07-06 作者:

As far as I know, the Mingle Forum is my favorite forum plugin of WP, but its only Cons is that the allowed uploading image size has no restriction.
I was a C programmer, but not touched it for almost 5 years, and yes I never touched PHP so far in my life. so it’s tough for me to add the restriction or resizing feature.
Then I realized that’s also ok if I can let it upload images to an isolated directory, since it could be easy to remove those images by whole directory from posts when the storage space is close to run out. Otherwise, all those images would stay together with Media library of WP posts/pages – quite hard to isolate them and get those stuff cleaned.

So you see, we get that standard WP media lib directory, then check and/or add “mf” sub-directory, and it’s perfectly solved.
Pls check the code enclosed at post bottom, feel free to refer but pls add link to this post; plus, pls let me know if there is any potential bug inside since it’s my 1st time to touch PHP.

PS: 1st time to read WP and PHP standard API manual, it’s “loud and clear”, not hard to learn, and I could even debug this stuff without error report – sure this one is easy and I know that. 🙂

Fisherworks今天一直在纠结使用哪个论坛插件的问题
bbpress在快速研究之下没找到合适的中文语言包
simple forum支持图像附件貌似还要个插件,而且这个论坛看起来比较专业,不是俺想要的

于是锁定了方便好配置的Mingle Forum,虽然默认皮肤集成不是很好,但这插件实在是太方便易用好配置了,而且默认支持图像附件的上传
但问题也跟着来了,它的图像附件是跟WP混在一个目录里上传的,而且不被WP“多媒体”管理
这都不算事儿,最关键的是Mingle Forum不限制图像尺寸(虽然显示时可以自动缩图,不会出错)
这样的话,每个用户都来发个5M的图像,这空间……

完整阅读本篇»