Image Upload resize
Permalinkfyi.
as soon as I know, I'll be sure to share..
-frz
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.
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
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