MyBB Community Forums

Full Version: [DEV][1.8] Image Upload Resize
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
So I have a forum running vBulletin 4 and is way past the point that I need to migrate to new forum software. I have decided to use MyBB as it fits most my needs, that being said our forum is image heavy and we needed a plugin that would resize images on the fly as they are uploaded to reduce storage space on the server.

I have tried all the other resizing plugins that i could find, but they seem to only resize the displayed image and not the actual image stored(could be wrong on this). Anyway here is my first attempt at a MyBB plugin. it is Alpha and not recommended for live sites.

this plugin uses MyBB thumbnail code to resize the image after upload and name change but before the actual thumbnail is created.

I am looking for any comments good, bad or indifferent to help me develop this plugin ie.. features, good coding practices  and so on

https://github.com/CoolMoon1/MyBB-Image-Upload-Resize


Image Upload Resize (IUR)

features:
  • resizes images on the fly as they are uploaded 
  • max width and height for new image while respecting ratio
  • setting for jpg compression (v0.2)

features working on:
  • override setting for admins and moderators to upload larger images(extra button maybe?)
  • ability to resize directories without breaking posts.
FYI: (since it's been asked.)

Default upload settings for PHP is 2M, this plugin will not/cannot change that. If you have access to your php.ini file you can change the 

"upload_max_filesize"  The maximum size of an uploaded file.

"post_max_size"    Sets max size of post data allowed. This setting also affects file upload. To upload large files, this value must be larger than upload_max_filesize. Generally speaking, memory_limit should be larger than post_max_size.

you may need to ask your hosting provider to increase these value if you do not have access.



Thanks CoolMoon
There's no problem with using code from MyBB's core files. I've also just taken a look at your code. For most instances within your code there's no input so there's actually no need to use $db->escape_string() when you're calling the argument from a language file. You could probably see Plugin Basics on a better way to handle adding your settings too.

You should probably also look at different MyBB functions to see how you can avoid using queries too.
Thanks wires,
I'll continue to look into the settings and haven't check through most of the functions yet, just the ones I thought I might need to get the job done.

Thanks again
Update to v0.2

-cleaned up code  
-added functions_resize_image.php (modified version of MyBB's functions_image.php)
-added compression setting
Is this plugin ready to be used on live forum now? I don't have a test env to test this but my forum is very quiet now so I'm able to run some tests.
From a quick look it might work but don't be surprised about some warnings, at least.
Interesting, I would be happy if you can also reduce the image sizes and enable compressions based on the reduced sizes.
Maybe @Kevin can take the challenge if @CoolMoon is no longer available.
https://community.mybb.com/thread-228956.html
Would be great to see a plugin in the future or even better this built directly into MyBB. Lost many users because of media restrictions, it's easier to upload to FB etc. than to post in a forum where you have to compress/resize your image.