The MU forums have moved to WordPress.org

Custom Header Help (Please?) :) (2 posts)

  1. chowanec
    Member
    Posted 16 years ago #

    Hi all,

    I've been getting by with no knowledge of PHP for a while now... :) I need your help at this point...

    I'm using the custom header API found in functions.php to allow users to upload their own header graphics. This part works great. What I would like to do, however, is turn off (i.e. override) the theme CSS if (and ONLY if) they have a custom image header... as people tend to put their blog name in the image header, so I want to turn off h1 and .description so the text is not in two places...

    Here's what I'm trying to do:

    define('HEADER_TEXTCOLOR', '');
    define('HEADER_IMAGE', '%s/images/header.jpg'); // %s is theme dir uri
    define('HEADER_IMAGE_WIDTH', 998);
    define('HEADER_IMAGE_HEIGHT', 113);
    define('NO_HEADER_TEXT', true);
    
    function header_style() {
    ?>
    <style type="text/css">
    #header{
    	background: #FFFFFF url(<?php header_image() ?>);
    	width:998px;
    }
    
    <?php
    	if (strlen(strchr(header_image(), 'themes')) > 0) {
    	echo ('#header #header_right {display: none;}');
    	}
    ?>
    
    </style>

    So, the if statement is the place I need help -- what I'm *trying* to do is check the output of header_image() for the word 'themes' at which point I will know they are using something non-default (as their uploaded images are stored in their files directory) and as such, turn off the header_right CSS.

    Thing is, whenever the php sees header_image() I end up with a line that looks like:

    <path.to.user.uploaded.image>#header #header_right {display: none;}

    That is to say, everything is smashed together... Is there anyway to capture the output of header_image() as a string so I can compare it?

    I'm sure I'm just a babbling moron. Anything you can do to help is appreciated...

    Thanks.

    -Chow

  2. chowanec
    Member
    Posted 16 years ago #

    Heh. I'm a moron. If you replace: header_image() with get_header_image() it works just fine. Oh, and change the > to == and it will actually DO what it is supposed to.

    Rookie move.

About this Topic

  • Started 16 years ago by chowanec
  • Latest reply from chowanec