1

Warning: A non-numeric value encountered in functions.php

I am using php 7.1.31. I am using Linux Centos Server. I have also tried to type casting. but not worked. When I have changed php version to 5.6. Same code was working.

Code is look like this

    $width        = 300;
            $height       = 300;
            $crop         = 1;
            if ( function_exists( 'wc_get_image_size' ) ) {
                $size   = wc_get_image_size( 'shop_catalog' );
                $width  = isset( $size['width'] ) ? $size['width'] : $width;
                $height = isset( $size['height'] ) ? $size['height'] : $height;
                $crop   = isset( $size['crop'] ) ? $size['crop'] : $crop;
            }    

foreach ( $product_size as $k => $w ) {
                    $w = intval( $w );
                    if ( isset( $width ) && $width > 0 ) {
                        $h = round( $height * $w / $width );
                    } else {
                        $h = $w;
                    }
                    add_image_size( $k, $w, $h, $crop );
                }

Warning: A non-numeric value encountered in theme/functions.php on line 165. I am getting issue in

$h = round( $height * $w / $width );

I tried to change it to

$h = (int)( $height * $w / $width );

but still same warning is coming.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.