Reputation: 43
I'm using wordpress in my blog, but I see repeated errors in error_log as below. How can I solve this problem?
Thanks.
error_log
[29-Nov-2015 12:01:14 UTC] PHP Warning: getimagesize(http://hardal.com/wp-content/uploads/2015/11/glogo.png): failed to open stream: HTTP request failed! in /home/hardal/public_html/wp-content/themes/hardal/header.php on line 36
[29-Nov-2015 12:01:14 UTC] PHP Warning: getimagesize(http://hardal.com/wp-content/uploads/2015/11/glogo21.png): failed to open stream: HTTP request failed! in /home/hardal/public_html/wp-content/themes/hardal/functions/theme-actions.php on line 38
theme-actions.php line 36 to 41
<div class="row" id="copyright-note">
<?php if ($albay_options['albay_footer_logo'] != '') { ?>
<?php list($width, $height, $type, $attr) = getimagesize($albay_options['albay_footer_logo']); ?>
<div class="foot-logo">
<a href="<?php echo home_url(); ?>" rel="nofollow"><img src="<?php echo $albay_options['albay_footer_logo']; ?>" alt="<?php bloginfo( 'name' ); ?>" <?php echo $attr; ?>></a>
</div>
header.php line 33 to 43
<?php if ($albay_options['albay_logo'] != '') { ?>
<?php if( is_front_page() || is_home() || is_404() ) { ?>
<h1 id="logo" class="image-logo">
<?php list($width, $height, $type, $attr) = getimagesize($albay_options['albay_logo']); ?>
<a href="<?php echo home_url(); ?>"><img src="<?php echo $albay_options['albay_logo']; ?>" alt="<?php bloginfo( 'name' ); ?>" <?php echo $attr; ?>></a>
</h1><!-- END h1-->
<?php } else { ?>
<h2 id="logo" class="image-logo">
<?php list($width, $height, $type, $attr) = getimagesize($albay_options['albay_logo']); ?>
<a href="<?php echo home_url(); ?>"><img src="<?php echo $albay_options['albay_logo']; ?>" alt="<?php bloginfo( 'name' ); ?>" <?php echo $attr; ?>></a>
</h2><!-- END h2-->
Upvotes: 2
Views: 7909
Reputation: 96
How can I solve this problem?
Well, seems you need to do more test about it for making sure what's the problem before start solving it.
The error_log
provided you some clues to let you know that is the getimagesize
function had a problem about HTTP request
when handling http://hardal.com/wp-content/uploads/2015/11/glogo.png
and another URL.
Because of this is linked to HTTP request
, to found out what exactly the error is, you may need $http_response_header
variable.
http://php.net/manual/en/reserved.variables.httpresponseheader.php
The $http_response_header array is similar to the get_headers() function. When using the HTTP wrapper, $http_response_header will be populated with the HTTP response headers. $http_response_header will be created in the local scope.
Notice this variable only available when the HTTP wrapper
is successfully connected to a HTTP server and that server did respond. If it's not a HTTP server or connection has failed, the $http_response_header
will be empty or not be set.
So, for debug (Or cause seeking) purpose, you can make some code like this:
getimagesize('http://hardal.com/wp-content/uploads/2015/11/glogo.png');
if (empty($http_response_header)) {
exit('Connection failed.');
}
// See if the response string contains `200`. works in `HTTP/1.1` at least
if (strpos($http_response_header[0], '200') === false) {
exit('HTTP Error: ' . $http_response_header[0]);
}
Run it, this will prints out more detailed error information. Then:
Notice: Remember to remove above debug-purposed code before back to production.
Upvotes: 2