Hello everyone,
Has anyone of you got the plugin “Resize Image On Upload” to work under Modx 3?
I changed the “require_once” path from “/core/model/phpthumb/phpthumb.class.php” to “/core/vendor/james-heinrich/phpthumb/phpthumb.class.php”. This was displayed as an error in the error log. But after the change I have no more errors in the logs but it still doesn’t work properly.
Has anyone had any experience with this?
Alternative question: How do you do that for your customers/authors who are not technically versed that images are reduced in size when uploading?
If the plugin property “log” is set to “Yes”, the plugin “ResizeImageOnUpload” should create a log file for each uploaded image with more information under core/cache/logs/. Maybe take a look at those files to make sure the file paths are correct.
When I test it in MODX 3, the plugin still seems to work.
The only problem I see, is when the image gets renamed on upload (system setting upload_translit = “Yes”). Because of a bug, the plugin code still gets the old file name and therefore can’t find the image file and resize it. To fix it, you may have to apply this pull request:
I tested it with the default settings and an image with the dimensions 3120x4208 pixels (7.04 MB). After the upload it has the dimensions 444x600 pixels and a size of 61.2 KB.
This is irrelevant. The plugin uses the phpThumb PHP library directly.
That’s why you had to change the path to “/core/vendor/james-heinrich/phpthumb/phpthumb.class.php”.
What PHP version are you using?
With PHP 8, I get an error on the line
if (array_key_exists($cur_dir, $config)) {
because $config is null. This seems to be fixed in the Github code:
I tested this with php 7.4 - 8.1…
The only error I have in the log is this:
(ERROR @ /core/vendor/james-heinrich/phpthumb/phpthumb.class.php : 1814) PHP warning: getimagesize(/assets/bilder/test/Druckertest-A4.jpg): failed to open stream: No such file or directory
If I simply make a call on the website, the images are calculated correctly.
[[!phpthumbof? &input=/assets/img/xxx.jpg &options=&w=640&h=480&zc=1&aoe=0&far=0]]
The images are then located as usual in “/core/cache/phpthumb/”
So is this path correct? By default it should get converted to lowercase letters!
Does it work if you use a file name with only lowercase letters? Did you apply the pull request I linked above?
Damn, it works with lower case letters now… The problem is that upper case letters are extremely common in our country. Now I just need to get something like “SanitizeUpload” working in Modx3.
In MODX 3, the names of uploaded images are automatically transliterated, if the system setting upload_translit is set to Yes.
The problem is, that the changes to the file name are not transmitted correctly to the “OnFileManagerUpload” event. But this pull request fixed the issue when I tested it.