NellieBird
Forum Replies Created
-
Forum: Themes and Templates
In reply to: Twenty Eleven header image resize not workingGreat!
Forum: Themes and Templates
In reply to: Twenty Eleven header image resize not workingIt doesn’t mean you have a smaller sized brain, just less knowledge. I placed a container (div) around my header image in header.php, and gave it the id=header_container. You can see it in the code below (the first and last line):
<div id="header_container"> <?php // Check to see if the header image has been removed $header_image = get_header_image(); if ( $header_image ) : // Compatibility with versions of WordPress prior to 3.4. if ( function_exists( 'get_custom_header' ) ) { // We need to figure out what the minimum width should be for our featured image. // This result would be the suggested width if the theme were to implement flexible widths. $header_image_width = get_theme_support( 'custom-header', 'width' ); } else { $header_image_width = HEADER_IMAGE_WIDTH; } ?> <a href="<?php echo esc_url( home_url( '/' ) ); ?>"> <?php // The header image // Check if this is a post or page, if it has a thumbnail, and if it's a big one if ( is_singular() && has_post_thumbnail( $post->ID ) && ( /* $src, $width, $height */ $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), array( $header_image_width, $header_image_width ) ) ) && $image[1] >= $header_image_width ) : // Houston, we have a new header image! echo get_the_post_thumbnail( $post->ID, 'post-thumbnail' ); else : // Compatibility with versions of WordPress prior to 3.4. if ( function_exists( 'get_custom_header' ) ) { $header_image_width = get_custom_header()->width; $header_image_height = get_custom_header()->height; } else { $header_image_width = HEADER_IMAGE_WIDTH; $header_image_height = HEADER_IMAGE_HEIGHT; } ?> <img src="<?php header_image(); ?>" width="<?php echo $header_image_width; ?>" height="<?php echo $header_image_height; ?>" alt="" /> <?php endif; // end check for featured image or standard header ?> </a> <?php endif; // end check for removed header image ?> <?php // Has the text been hidden? if ( 'blank' == get_header_textcolor() ) : ?> </div> <!-- #header_container -->
Then I gave the header_container its dimensions and position in my (child)theme’s style.css:
#header_container { position: absolute; top: 10px; left: 380px; width: 370px; height: 175px; z-index: 9999; }
Hope that helps!
Forum: Themes and Templates
In reply to: Twenty Eleven header image resize not workingThx aikorei for your reply. In the mean time I’ve worked out something that does what I want: I pasted the code below in my functions.php, and in addition to that I placed a div around the header img in my header.php. I gave the div the exact dimensions of what I want the pic to be. That did it.
remove_filter( 'HEADER_IMAGE_WIDTH', 'twentyeleven_header_image_width' ); remove_filter( 'HEADER_IMAGE_HEIGHT', 'twentyeleven_header_image_height' ); define( 'HEADER_IMAGE_WIDTH', apply_filters( 'child_header_image_width', 370 ) ); define( 'HEADER_IMAGE_HEIGHT', apply_filters( 'child_header_image_height', 175 ) );
Forum: Themes and Templates
In reply to: Twenty Eleven header image resize not working@aikorei: could you please put down the code that you used in your child’s functions php and/or any other code you used to make it work? I did put the underneath code in my child’s functions.php, yet still have the problem as you mentioned at first. In the Appearance > Header it even shows the preview in the right dimensions, but on the actual page it shows stretched to 1000px.
$defaults = array( 'default-image' => '', 'random-default' => false, 'width' => 370, 'height' => 175, 'flex-height' => false, 'flex-width' => false, 'default-text-color' => '', 'header-text' => true, 'uploads' => true, 'wp-head-callback' => '', 'admin-head-callback' => '', 'admin-preview-callback' => '', ); add_theme_support( 'custom-header', $defaults );
that worked, by adding
remove_filter('dbem_notes', 'wpautop');
Not sure what effect that will have on my other pages, but as for now this is fixed. Thanks!