When saving the settings page (in dev and 7.x-1.4):
Fatal error: Call to undefined function max_image_size_variable_settings_form_submit() in /home/public_html/drupal-7/includes/form.inc on line 1519

Comments

Anonymous’s picture

cmseasy created an issue. See original summary.

Anonymous’s picture

Solution:
The Filesize threshold field needs some input.
Please make it required with default value 0

Sorry: didn't workout

steven.wichers’s picture

I'm not really sure why it would be trying to call that function. Nothing in the code references it. Can you duplicate this on a clean install?

Anonymous’s picture

Status: Active » Closed (works as designed)

Thanks for the respons.
I made a test on another site (not a clean install): no problems on that domain with Max Image Size.

My Call to function error is not from Max Image Size, so I have some search work to do.......
Closing this issue.

cp4w’s picture

Hi guys,

I get the same error message. Indeed, I don't think it's coming from this module. I suspect "File Entity" but not sure.

Anyway, the error is raised when saving settings form. So, I "solved" this problem by... not using UI :-)

Just declare your variables in your settings file

Eg:

$conf['max_image_size_width'] = 600;
$conf['max_image_size_height'] = 450;
$conf['max_image_size_filesize_threshold'] = 180000;
$conf['max_image_size_cron_enabled'] = 0;
$conf['max_image_size_presave_enabled'] = 1;

But... btw... I tried then, with the above configuration, to upload a 5,4 Megas picture (4320 × 3240).

The image has been resized, but it's size is 2133 × 1600 (and 295 KB).

And that I don't understand. I was expecting a 600 X (ratio as height) image....

Did I understand something badly ?

Thanks... this is a nice module...

steven.wichers’s picture

If you go to the UI does it show your 600x450 or does it show something else? The defaults are 2560x1600, which would explain your 2133x1600, so it doesn't seem like your settings are getting used.

cp4w’s picture

No, it shows 600X450.

But I understand...

- What I need actually: if my picture is "landscape-oriented", I want a resulting image of 600x(height ratio). If my image is "portrait-oriented", I want a (width ratio)X450.
- But in your module, weight and width are mandatory. So when you give width AND height, the "image_scale" function you're using is calculating a kind of "best-matching-ratio" between the provided width and height (don't know if it's clear... I hope so :-) ).
- If you check "image_scale" documentation (https://api.drupal.org/api/drupal/includes!image.inc/function/image_scal...), you can read for "height" param: "If this value is NULL then the scaling will be based only on the width value.", and same for "width" param.
- And this is exactly what I need... be able to set NULL as height or width.

I tried it by updating line 253 (dev version) of max_image_size.module, like this (just for the test):

if (!image_scale($image, $dimensions['width'], NULL)) {

And my resulting image = 600X450

So, your module is really good, useful, but incomplete I think.

It would be awesome if HEIGHT or WIDTH could be set to NULL through configuration.

What d'you think ?

steven.wichers’s picture

If the UI is showing your settings that is what the module should be using, so maybe there is a bug there somewhere.

I also think there might be some confusion around this modules use. I believe you are trying to use it as a way to enforce some image styles.

This module's purpose is to allow people to upload huge images, but then resize that image to a max width/height for later use. If you want to allow your users to upload huge images, but not actually store the uploads as huge files, then you would use this module.

For example: A user uploads an image at 12,500 x 9,500 resolution. This module is set to enforce image sizes to be within 4,000 x 3,000. It will resize the user's upload to be 4,000 x 3,040 pixels. You would then use Drupal's image styles to create other image sizes based on your needs from that 4,000 x 3,040 source image while leaving it untouched.

Another way to think of it is we know we'll never need an image bigger than a certain size so any images bigger than that size can be scaled down to that desired size. We don't want to scale them down to a thumbnail size in case we need other (larger) sizes later.

See:

https://www.drupalgardens.com/documentation/working-image-styles

https://www.drupal.org/project/imagecache

cp4w’s picture

No, I confirm that I don't want to keep the big sized image.

But I want to be able to resize following width OR height which is not possible with your module. But the image_scale function works like that. In my previous example, if I want a resulting 600x450 image, I have to use image_scale function by passing 600 as width and null as height.

A little bit like if would resize an image in Photoshop. You fill the width and the height is auto set.

But if we're still not on the same wave... it's OK, your module saves me some precious time. I have to adapt a few lines to fit my needs. And thanks for that ! :-)

++

(And sorry for my strange English :-) )

steven.wichers’s picture

This module isn't designed to give you specific image dimensions. It's designed to scale the image to be within a certain box size. You would then use image styles to get the exact proportions you wanted. Resizing an image in Photoshop is like using the image style functionality of Drupal. This module is closer to changing the size of the photo your camera takes.

You would set your camera to take an 8MP picture and then use Photoshop to get the specific image sizes/dimensions you wanted. You would use this module to limit images to a certain max size and then use image styles to get the specific image sizes/dimensions you wanted.

To use smaller numbers to help the concept.

User uploads 1000x1000 pixel images. I only want the maximum image size to be 800x600. To be clear, this is not the size of the image I will display on the website. It is simply the maximum size I would like image sources to be. I then create image styles for 480x320, 100x500, etc. Drupal uses my resized source image to create those 480x320 image thumbnails. If I ever want to create a 700x500 image I can because my source image is still within the 800x600 box I set.

What you are describing is exactly what image styles are used for. You can set only a width or a height and it will resize a copy of the image exactly how you want.

If you are saying you will never show these images any other way, and want them to always be 600x450 then this module's purpose isn't really to substitute Drupal image styles. I would also recommend against using this module to resize images in that way. Down the line you may find you want images to be 650x500 or some other size and now all your high-res images are useless.

cp4w’s picture

OK I understand what you say.

But image styles keeps the original image.

I want to avoid the user to upload a too big image.

So I say: if your upload is bigger than 600px width. I want it to be resized to 600px. And adapt the height automatically. Like image styles indeed. And the 600px width image is the source image I want to keep on my server.
Then I could still use image styles if I have to display it smaller on the website.

I need something between what you explain and image styles I think.

So, image_scale function does exactly that. You use the function but through your module we can't give it a null value as width or height. This is the only thing I find strange.

steven.wichers’s picture

Let's say someone uploads a 300,000 x 600 picture. With what you are asking that picture would not get resized because it's at your 600 width restriction. This is why both a width and height are required, so the module knows the bounding box you want images to fit within.

abh.ai’s picture

Assigned: Unassigned » abh.ai

This issue still exists. I just submitted the form and I get the error

Fatal error: Call to undefined function max_image_size_variable_settings_form_submit() in ../form.inc

Submit function is used instead of validate. Changed it and fixed in attached patch.

abh.ai’s picture

steven.wichers’s picture

Assigned: abh.ai » Unassigned

Please see https://www.drupal.org/node/2826461

Patches that are avoiding the actual bug will not be accepted. Swapping to a validate function is both using the validate hook incorrectly and not actually identifying the bug. The code in the submit handler does not do any validation. Drupal forms should be able to add a submit handler without error.