Author Topic: Media Image Auto Resize on Upload  (Read 1335 times)

Offline sky writer

  • Posts: 926
Media Image Auto Resize on Upload
« on: May 26, 2017, 09:02:57 PM »
Most of my client websites have large Media folder structures, and setting max width/height for every individual folder is cumbersome, and therefore most clients simply don't do it or forget when they create new folders.

That said, i have always used the workaround explained in this thread - https://forum.WebsiteBaker.org/index.php/topic,22848.msg154266.html#msg154266

WB/admin/media/upload.php. Change lines 108-114 from:

Code: [Select]
if(file_exists($relative.$filename)) {
   if ($pathsettings[$resizepath]['width'] || $pathsettings[$resizepath]['height'] ) {
      $rimg=new RESIZEIMAGE($relative.$filename);
      $rimg->resize_limitwh($pathsettings[$resizepath]['width'],$pathsettings[$resizepath]['height'],$relative.$filename);
      $rimg->close();
   }
}

to:

Code: [Select]
if(file_exists($relative.$filename)) {
   if ($pathsettings[$resizepath]['width'] || $pathsettings[$resizepath]['height'] ) {
      $rimg=new RESIZEIMAGE($relative.$filename);
      $rimg->resize_limitwh($pathsettings[$resizepath]['width'],$pathsettings[$resizepath]['height'],$relative.$filename);
      $rimg->close();
   }
   else {
      $rimg=new RESIZEIMAGE($relative.$filename);
      $rimg->resize_limitwh('1024','768',$relative.$filename);
      $rimg->close();
   }
}

But again, this requires a manual change to the core code after each upgrade.  I'm not lazy, but sometimes things get missed when working on multiple sites in multiple stages of development.

I am wondering if it has ever been considered by the dev team to implement this setting into the core code?  Or perhaps having global max width and height variables which could be set on the Media admin page or the Advanced Settings page?

This would be very useful.  Thanks for your consideration.

Offline dbs

  • Betatester
  • **
  • Posts: 7854
  • Gender: Male
  • tioz4ever
    • WebsiteBaker - jQuery-Plugins - Module - Droplets - Tests
Re: Media Image Auto Resize on Upload
« Reply #1 on: May 27, 2017, 09:49:35 AM »
This would be a good feature.  (Y)
I will open a ticket, additionally to your post here.

Offline grawi

  • Posts: 16
Re: Media Image Auto Resize on Upload
« Reply #2 on: June 02, 2017, 10:49:46 PM »
Hi
I would like to add my two cents. It is not good idea to resize image during uploading to media folder.
If for example there are kept images for big slider - width higher then 1024px - it will not be possible to upload slider images via backend. 

Grawi

Offline jacobi22

  • Posts: 5770
  • Gender: Male
  • Support also via PM or EMail
    • Jacobi22
Re: Media Image Auto Resize on Upload
« Reply #3 on: June 03, 2017, 02:05:25 AM »
@grawi: its possible in media/modify-settings to set a resize value (width & height) for every subfolder from media-directory, so for example maybe also 2400px (or more) max-width in a fictive folder called big_slider or background_slider - for the pictures in your example
and only, if nothing is defined, the workaround from sky_writer works as globale resize setting.
from my point and without tests at this time, i think, it has to work  - okay, its a little bit more to do for the admins - add a folder (if needed), set width & height for this folder, before you uplod some pics there...
whats the best solution here?
Probleme sind da, um sie zu lösen, nicht, um nach Ausreden zu suchen.

Offline sky writer

  • Posts: 926
Re: Media Image Auto Resize on Upload
« Reply #4 on: June 03, 2017, 05:45:54 AM »
okay, its a little bit more to do for the admins - add a folder (if needed), set width & height for this folder, before you upload some pics there...
whats the best solution here?

For me, the current process is MUCH more work for the admins.

I can only speak from my experience with websites and clients.  I have not had any clients who need large resolution (anything over 1024 width) images for their sites.  So, if I do not implement my references workaround code, I have to manually add max width and height for EVERY media/folder and also direct my clients to do so for any new folder they create.

If you do have an OPTIONAL global setting as I am proposing, then it is overridden by any max value input in the Media/Modify Settings dialogue.  So, as jacobi22 noted, you can still have manually selected folders which allow higher resolution images.  Or, you can simply not impose the global settings, and WB works as it currently does.

Offline jacobi22

  • Posts: 5770
  • Gender: Male
  • Support also via PM or EMail
    • Jacobi22
Re: Media Image Auto Resize on Upload
« Reply #5 on: June 03, 2017, 11:55:52 AM »
P.S.: we discuss a solution like this in the last days, before we publish the WB 2.10.0, but at this point we has a feauture freeze. idea was a editable size in the globale wb-setting like your values as standard, nearly the same like your solution, but editable in the ACP
Probleme sind da, um sie zu lösen, nicht, um nach Ausreden zu suchen.

Offline CodeALot

  • Posts: 416
  • Gender: Male
Re: Media Image Auto Resize on Upload
« Reply #6 on: June 03, 2017, 12:26:23 PM »
Hi
I would like to add my two cents. It is not good idea to resize image during uploading to media folder.
If for example there are kept images for big slider - width higher then 1024px - it will not be possible to upload slider images via backend. 

Grawi
Then set the maximum width to 1920 pixels. Problem solved.
At least you would not end up with "straight out of camera" images in the media-folders, 6000 pixels wide and way too heavy in filesize for a website.
 
Expecting site-admins to set maximum values for every directory they create  (if they create any at all) is very, very unrealistic.

Offline sky writer

  • Posts: 926
Re: Media Image Auto Resize on Upload
« Reply #7 on: June 03, 2017, 03:35:08 PM »
at this point we has a feauture freeze.

I understand.  My personal workaround is to add the custom code to my WB installation files, so all new installs and upgrades have the media size restriction as default.
I did the same with the signup.php and signup2.php fixes.

Hopefully there will be some consideration for this feature in the next WB version.