Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHP Notice in random image module #23766

Closed
jjnxpct opened this issue Feb 4, 2019 · 8 comments
Closed

PHP Notice in random image module #23766

jjnxpct opened this issue Feb 4, 2019 · 8 comments

Comments

@jjnxpct
Copy link

jjnxpct commented Feb 4, 2019

When using the random image module we get a PHP notice:

Backend log: PHP Notice: A non well formed numeric value encountered in /home//domains//public_html/modules/mod_random_image/helper.php on line 52\n

System information (as much as possible)

Joomla! 3.9.2
PHP 7.2.13

Additional comments

Line 52 is:
$newheight = min($height, (int) ($width / $coeff));

I think maybe this would work:
$newheight = min($height, ((int) $width / (int) $coeff));

Not sure if that's the right way to fix it.
And maybe it needs to be changed on more line in the module.

@tonypartridge
Copy link
Contributor

Curious to what height / width values you are using?

@jjnxpct
Copy link
Author

jjnxpct commented Feb 5, 2019

They are empty...

@Quy
Copy link
Contributor

Quy commented Feb 5, 2019

@jjnxpct Is this happening with all images or randomly?

@jjnxpct
Copy link
Author

jjnxpct commented Feb 5, 2019

I believe this is happening with all images. But when I tested this I noticed that after opening the module in the backedn and saving it there was a default '100' set in the width field. Making this empty and then saving the module put the '100' back again. And now the images are all 100 px in stead of 100%.

So I now changed the default.php view by hardcoding '100%' in the image width to fix this on this site. (It might also work with CSS setting the width to 100% !imnportant))

I guess it was still working on the site until I opened and saved the module. Maybe because of changes to the module code in the recent past?

Anyway can you reproduce this with behavoiur (defaulting to 100 when left empty)? Or is this intended?

The PHP notices might be related to this? Or not?

@SharkyKZ
Copy link
Contributor

SharkyKZ commented Feb 6, 2019

I can't reproduce the notices. I did touch this module in #20856 but (intentionally) left its functionality as it was. I don't see how it was possible to set the width to 100% because when no value was entered, it defaulted to 100px:

if ($width == '')
{
$width = 100;
}

@jjnxpct
Copy link
Author

jjnxpct commented Feb 6, 2019

Hi! It's strange, but I don't see the PHP notices anymore. Also I reverted back to the original module code. I used CSs to set the image width to 100% so that is being used in the template in stead of the 100px setting in the module.

We use 100% because we want the image to scale with the browser width.

I guess no need for changes then ;-) Thanks for your help!

@joomla-cms-bot
Copy link

Set to "closed" on behalf of @Quy by The JTracker Application at issues.joomla.org/joomla-cms/23766

@Quy
Copy link
Contributor

Quy commented Feb 6, 2019

Closing as no-reproducible.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/23766.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants