Read Custom Header Image Size
-
Hi everybody.
I’ve changed functions.php with following lines://======================
// get current theme name
$theme_name = get_current_theme();// header image themes default folder
define( ‘HEADER_IMAGE’, ‘%s/images/header.jpg’ );// get header image size (width, height)
list($width, $height) = getimagesize(‘../wp-content/themes/’ . $theme_name . ‘/images/header.jpg’);// read width of header image
define( ‘HEADER_IMAGE_WIDTH’, apply_filters( ”, $width ) );
// read height of header image
define( ‘HEADER_IMAGE_HEIGHT’, apply_filters( ”, $height ) );
define( ‘NO_HEADER_TEXT’, true );// enable Dashboard Appearance > Header
add_custom_image_header( ”, ‘admin_header_style’ );// Code is for Styling the Admin Side
if ( ! function_exists( ‘admin_header_style’ ) ) :
function admin_header_style() {
?>
<style type=”text/css”>
#heading {
height: <?php echo HEADER_IMAGE_HEIGHT; ?>px;
width: <?php echo HEADER_IMAGE_WIDTH; ?>px;
}
#heading h1, #heading #desc {
display: none;
}
</style>
<?php
}
endif;//======================
When I launch the dashboard Appearence –> Header to change header image, the function getimagesize() works fine and the image dimensions are ok.
(You can upload a custom header image to be shown at the top of your site instead of the default one. On the next screen you will be able to crop the image.
Images of exactly 874 × 200 pixels will be used as-is.)
————-
But, when I launch the site I receive this error message:Warning: getimagesize(../wp-content/themes/winter/images/header.jpg) [function.getimagesize]: failed to open stream: No such file or directory in C:\xampp\htdocs\blognoster\wp-content\themes\winter\functions.php on line NNN
where NNN is the line:
list($width, $height) = getimagesize(‘../wp-content/themes/’ . $theme_name . ‘/images/header.jpg’); // get header image
————
Needs an helps.
Thanks.
The topic ‘Read Custom Header Image Size’ is closed to new replies.