OLSA Posted October 2, 2015 Share Posted October 2, 2015 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 More sharing options...
horst Posted October 2, 2015 Share Posted October 2, 2015 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 More sharing options...
Juergen Posted October 2, 2015 Share Posted October 2, 2015 Same problem here, but with image focus area fieldtype. https://processwire.com/talk/topic/8079-imagefocusarea/?p=103424 I use the latest php version. Best regards Link to comment Share on other sites More sharing options...
horst Posted October 2, 2015 Share Posted October 2, 2015 (edited) I use the latest php version. PHP 7 ? (just kidding) Edited October 2, 2015 by horst Link to comment Share on other sites More sharing options...
OLSA Posted October 2, 2015 Author Share Posted October 2, 2015 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 1 Link to comment Share on other sites More sharing options...
horst Posted October 2, 2015 Share Posted October 2, 2015 Thanks for reporting this and the part reported by @Juergen. Link to comment Share on other sites More sharing options...
ryan Posted November 6, 2015 Share Posted November 6, 2015 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 More sharing options...
Peter Falkenberg Brown Posted November 6, 2016 Share Posted November 6, 2016 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 More sharing options...
adrian Posted November 6, 2016 Share Posted November 6, 2016 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. 3 Link to comment Share on other sites More sharing options...
Peter Falkenberg Brown Posted November 6, 2016 Share Posted November 6, 2016 Thanks, Adrian! I pulled the values out of the config.php in wire, and used those, with some tweaks, and the errors went away! I'm so delighted with ProcessWire I could just dance a jig. Peter 2 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now