tony09uk
tony09uk

Reputation: 2991

working with wordpress logos

I have created a blog using wordpress, it has been developed on my localhost and the theme is the LUGADA Theme found here.

I want to add a logo which is bigger than the specfied size in theme that has been specified as 300 x 70 by the designer. When I try and upload a new logo using the facility they provide, it forces me to crop the image to their required size, how do I get around this?

I looked at header.php and found this:

<img src="<?php header_image(); ?>" width="<?php echo HEADER_IMAGE_WIDTH; ?>" height="<?php echo HEADER_IMAGE_HEIGHT; ?>" alt="" />

I have tried taking HEADER_IMAGE_WIDTH and HEADER_IMAGE_HEIGHT out but the upload facility forces me to crop the image

I have considered hardcoding the logo in but want it to still be available when I change the theme. I have also tried tracking down header_image(), which I found in wp-includes/theme.php but could not work out what to do from there.

Could someone please advise how I put a logo sized to my requirements in please?

Upvotes: 2

Views: 154

Answers (1)

Jared Cobb
Jared Cobb

Reputation: 5267

There are a couple of tweaks to this theme that I would recommend, and they should achieve the results you're looking for.

First, the theme is currently using a deprecated method (add_custom_image_header) in order to allow you to upload your logo. Let's temporarily stop that, use a newer function, and if you're happy with the results you can follow my instructions to clean up the code.

  1. Open functions.php and find lines 135, 136, and 176 and comment them out:

    //define('HEADER_IMAGE_WIDTH', 300); // use width and height appropriate for your theme
    //define('HEADER_IMAGE_HEIGHT', 300);
    
    //add_custom_image_header('lugada_header_style', 'lugada_admin_header_style');
    
  2. Add the following code after line 176:

    $header_defaults = array(
        'width'=>300,
        'height'=>200,
        'flex-height'=>true,
        'flex-width'=>true
    );
    add_theme_support( 'custom-header', $header_defaults );
    
  3. In your header.php file, go ahead and replace line 68 with this code (remove the width and height attributes):

    <img src="<?php header_image(); ?>" alt="" />
    

Some notes on this code...

  • You're now using a newer method for the custom header logo. This means you'll have fewer problems upgrading WordPress in the future
  • Your now using flexible height and width so you can crop however you wish
  • You can change those height and width values to whatever you wish (for defaults)
  • You can find more information about the usage of add_theme_support here, and you may find even more helpful options.

If you're happy with the results and want to clean up the code you can delete lines 135, 136, and 176 and delete the two functions named lugada_header_style and lugada_admin_header_style.

Have fun!

Upvotes: 2

Related Questions