Jump to content

"Warning" in Pageimage.php [2.6.1... 2.6.18]


OLSA
 Share

Recommended Posts

Hello for all.

Just want to inform about "warning" (not error) in core/Pageimage.php, line 312.

Scenario:

1. set debug mode (config.php, $config->debug = true;)

2. crop image with api in template with additional "cropping" params:

$small_image = $page->image->size(200, 120, $options['cropping'] = '50%,40%');

You will get this message (example is from my localhost, MS Windows):

Warning: strpos() expects parameter 1 to be string, array given in ...\wire\core\Pageimage.php on line 312

If you use this format "50%x40%" ("x" separated, not with comma ",") than there is no warning message.

For interested, reason for that (if using comma separated values) is on line 277, 278.

Possible temporary fix solutions:

1. additional check inside "if" statement

if(!is_array($options['cropping']) && strpos($options['cropping'], 'x')... // line 312, core/Pageimage.php

or

2. using error control operator in "if" statement (line 312, core/Pageimage.php)

if(@strpos($options['cropping'], 'x') === 0 && preg_match('/^x(\d+)[yx](\d+)/', $options['cropping'], $matches))

or ...

Regards.

Link to comment
Share on other sites

I have two questions:

What PHP version do you use on that server?

and: Why do you use this format with double-qoutes wrapped with single-quotes? '"50%,40%"'

or: Have you also tried it with only one of them, (only single-quotes and / or only double-quotes)?

Link to comment
Share on other sites

Thanks Horst for reply.

What PHP version do you use on that server?

 PHP 5.4.1, but also same message on shared host (Linux, PHP >5.4)


and: Why do you use this format with double-qoutes wrapped with single-quotes? '"50%,40%"'

or: Have you also tried it with only one of them, (only single-quotes and / or only double-quotes)?

sorry it's mistake writing it here (there I have one variable), yes also try all options single/double quotes

  • Like 1
Link to comment
Share on other sites

  • 1 month later...

Thanks guys, I've added an additional check for this. Regarding the use of a cropping string like "50%,40%" to the size() method, does this work? It doesn't seem to do anything for me. The capability is one that was added from a PR a long time ago, and one I've not ever had the occasion to use in production. But just testing it now, it doesn't seem to do anything at all other than return a resized image without cropping?

$small_image = $page->image->size(200, 120, $options['cropping'] = '50%,40%');

The $options['cropping'] = '50%,40%' just resolves to a string of '50%,40%', whereas it looks to me like your intention is to provide an array to the size() method. Wouldn't it be better to do one of the following?

// just provide a string
$page->image->size(200, 120, '50%,40%');

// provide an array
$page->image->size(200, 120, array('cropping' => '50%,40%'));
Link to comment
Share on other sites

  • 11 months later...

Hi Folks,

Not sure if this should be a new thread or not, but since this is related to the Pageimage file, I thought I'd post it here.

I just upgraded to PW 3.0.39 on a staging domain. The only error I've seen so far (with debug=>true) is when I click on the Files menu. At the top of the page, I get 4 or 5 of these errors:

Notice: Undefined index: sharpening in /home/... path .../public_html/wire/core/Pageimage.php on line 506

I'm running on CentOS with PHP 5.6.27.

Yours,

Peter

Link to comment
Share on other sites

46 minutes ago, Peter Falkenberg Brown said:

Notice: Undefined index: sharpening in /home/... path .../public_html/wire/core/Pageimage.php on line 506


Looks like you might be defining $config->imageSizerOptions in your config file, but missing the "sharpening" option. Add that and you should be fine.

  • Like 3
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...