Image Upload resize

Permalink
Has anyone mod the file upload to be able to change the H and W on upload? seeing most people taking maga pix photo are way to big for web use?

wizardontherun
 
ScottC replied on at Permalink Reply
ScottC
Every upload appears to flows through the library_file block controller that is located in concrete/blocks/library_file/controller.php

If you want, haven't tested it, is you could make a copy of that file outside of concrete in the correct structured directory format, and hard-code in some values or throw them in config or something and read from there, or hell XML would work decent for that.

Anyways there appears to be some file resizing and file parameters right in the controller there.

I will be touching this over the weekend so speculative for now and concrete treats core blocks like the library_file differently since they are internal. In the time it took to post this I could have concrete answer for you, figures :)

Good luck.

-Scott
frz replied on at Permalink Reply
frz
in the new year we'll be dramatically revising the file manager and it will include a image resizer app..

fyi.
jgarcia replied on at Permalink Reply
jgarcia
Hey frz, do you guys have any sort of schedule as to how soon this feature would be added?
frz replied on at Permalink Reply
frz
the image resizer would be part of the file manager. It's on the top of Andrew's development roadmap. I'm not sure its on the top of mine. I know it needs to happen soon this year, but i think it comes down to who is paying our bills for the next couple of months - which I think is looking like ecommerce integration.


as soon as I know, I'll be sure to share..

-frz
jgarcia replied on at Permalink Reply
jgarcia
I know this is probably not best practice, since I am modifying the C5 core here, but here's a quick fix to prevent (well, technically it doesn't prevent) users from uploading huge images:

I added the following function to /concrete/blocks/library_file/controller.php

function shrinkImage($existingFile) {
   if (file_exists(DIR_FILES_UPLOADED . '/' . $existingFile)) {   
      LibraryFileBlockController::createImage(DIR_FILES_UPLOADED . '/' . $existingFile, DIR_FILES_UPLOADED . '/' . $existingFile, '450', '450');
   }
}


And then, in the "save" function in the same file, I just added this bit of code:

if ($generictype == 'image') {
   //If it's an image that's larger than 450 pixels wide, shrink it down to 450 pixels wide
   LibraryFileBlockController::shrinkImage($filename);
}


Of course, in this example the 450px max is hard-coded in, but with a little tweaking that value could be configurable.
snowman replied on at Permalink Reply
I'd like to see the new file manaer include the following:

1. for a site, the option to specify the max width and max height

2. option to allow only width or height to be specified so images scale ok.

3. compression on file upload to limit the file size of an image to a configurable size for the site.

Thanks
hursey013 replied on at Permalink Reply
hursey013
Is this code still valid - it's exactly what I'm looking for but its a couple years old, just wondering if you still use it successfully?