plugins - Wordpress shows error related to allow_url_fopen

admin2025-01-07  3

I just installed wordpress with plugins, everything works find except on a 'contact me' page, where I can see an error like this.

Warning: getimagesize(): php_network_getaddresses: getaddrinfo failed: Name or service not known in /var/www/foobar/wp-content/themes/foobar/backend/theme-components/cs-header/cs_functions.php on line 751

Warning: getimagesize(/wp-content/uploads/2015/11/subheader-image-jobline-1.jpg): failed to open stream: php_network_getaddresses: getaddrinfo failed: Name or service not known in /var/www/foobar/wp-content/themes/foobar/backend/theme-components/cs-header/cs_functions.php on line 751

cs_functions.php on line 751 is:

    if (is_file($cs_upload_dir . $cs_img_name) || is_file($cs_images_dir . $cs_img_name)) {
        if (ini_get('allow_url_fopen')) {
            if ($header_banner_image <> '') {
                $banner_image_height = getimagesize($header_banner_image);
            }
        }
    } else if (isset($cs_upload_subdir_file) && is_file($cs_upload_dir . $cs_upload_subdir_file)) {
        if (ini_get('allow_url_fopen')) {
           // THIS IS LINE 751
          $banner_image_height = getimagesize($header_banner_image);
        }
    } else {
        $banner_image_height = '';
    }

So, I went to /etc/php.ini and checked allow_url_fopen and it is set to on

allow_url_fopen = On

What is going on? and how do I fix it

I just installed wordpress with plugins, everything works find except on a 'contact me' page, where I can see an error like this.

Warning: getimagesize(): php_network_getaddresses: getaddrinfo failed: Name or service not known in /var/www/foobar.com/wp-content/themes/foobar/backend/theme-components/cs-header/cs_functions.php on line 751

Warning: getimagesize(http://dev.foobar/wp-content/uploads/2015/11/subheader-image-jobline-1.jpg): failed to open stream: php_network_getaddresses: getaddrinfo failed: Name or service not known in /var/www/foobar.com/wp-content/themes/foobar/backend/theme-components/cs-header/cs_functions.php on line 751

cs_functions.php on line 751 is:

    if (is_file($cs_upload_dir . $cs_img_name) || is_file($cs_images_dir . $cs_img_name)) {
        if (ini_get('allow_url_fopen')) {
            if ($header_banner_image <> '') {
                $banner_image_height = getimagesize($header_banner_image);
            }
        }
    } else if (isset($cs_upload_subdir_file) && is_file($cs_upload_dir . $cs_upload_subdir_file)) {
        if (ini_get('allow_url_fopen')) {
           // THIS IS LINE 751
          $banner_image_height = getimagesize($header_banner_image);
        }
    } else {
        $banner_image_height = '';
    }

So, I went to /etc/php.ini and checked allow_url_fopen and it is set to on

allow_url_fopen = On

What is going on? and how do I fix it

Share Improve this question edited Mar 5, 2017 at 7:46 David Lee 3,9413 gold badges14 silver badges20 bronze badges asked Mar 5, 2017 at 3:08 user7342807user7342807 1113 bronze badges 2
  • you should basically never call getimagesize on a url. this will slow down your page tremendously. – Joel M Commented Feb 16, 2020 at 15:24
  • call it on the file path not the url. url starts with http, path starts with ABSPATH constant (in WordPress) – Joel M Commented Feb 16, 2020 at 15:26
Add a comment  | 

1 Answer 1

Reset to default 0

I'm assuming WP is installed locally, did you make sure to edit your hosts file. Example:

127.0.0.1 dev.foobar
转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1736258271a500.html

最新回复(0)