• Resolved chibib0

    (@chibib0)


    Hi,

    I’m using the twenty ten theme as my framework on my themes. However, i have themes that needs to have defined width and height of the header image different on the twenty ten default.

    I have defined the height and width on the theme however, the default height and width of twenty ten is still defined on the backend so when cropping the uploaded image, the default height and width is the crop size.

    Is there a solution for this?
    Thank you.

    https://www.ads-software.com/extend/themes/twentyten/

Viewing 6 replies - 1 through 6 (of 6 total)
  • esmi

    (@esmi)

    Do not edit the Twenty Eleven theme. It is the default WordPress 3.2 theme and having access to an unedited version of the theme is vital when dealing with a range of site issues.

    Create a child theme for your customisations. Once your child theme is active, see this article.

    peredur

    (@peredur)

    The image is inserted using the following code in header.php:

    // Check if this is a post or page, if it has a thumbnail, and if it's a big one
    if ( is_singular() && current_theme_supports( 'post-thumbnails' ) && has_post_thumbnail( $post->ID ) && ( /* $src, $width, $height */ $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'post-thumbnail' ) ) && $image[1] >= HEADER_IMAGE_WIDTH ) :
      // Houston, we have a new header image!
      echo get_the_post_thumbnail( $post->ID );
    elseif ( get_header_image() ) : ?>
      <img src="<?php header_image(); ?>" width="<?php echo HEADER_IMAGE_WIDTH; ?>" height="<?php echo HEADER_IMAGE_HEIGHT; ?>" alt="" />
    <?php endif; ?>

    You best bet is probably is probably either to redefine the constants HEADER_IMAGE_WIDTH and HEADER_IMAGE_HEIGHT or to just hard code in the image you want.

    As it’s the twentyten theme, you really *must* do this in a child theme.

    HTH

    PAE

    Thread Starter chibib0

    (@chibib0)

    @peredur

    When i redefine the constants HEADER_IMAGE_WIDTH and HEADER_IMAGE_HEIGHT by creating a functions.php inside the child theme there is a “Cannot Redeclare Error”.

    esmi

    (@esmi)

    peredur

    (@peredur)

    First off, of course, esmi is correct.

    As for the constants, I’m sorry, I misled you. You can’t redefine a constant. You need to make sure that the function in which the constants are defined is overwritable. I.e. it should be surrounded by:

    if(!function_exists('function_name')) {
        ...
    }

    That being the case, you can create another function of the same name in your child theme by copying the old one into your functions.php file and changing the bits you need to change.

    In twentyten the function is called twentyten_setup(). I’m not sure about twentyeleven, but it should be similar.

    Sorry about the confusion

    Cheers

    PAE

    Thread Starter chibib0

    (@chibib0)

    Thank you guys! It works! ^_^v

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘[Theme: Twenty Ten] How to define the header image width and height?’ is closed to new replies.