25
Jan
05

HeadImage Wordpress Plugin

I’ve created a plugin for Wordpress that will change the header background of a page based on a custom field for the first post on that page. This was requested by my buddy Walter Costinak and you can see it in action on his blog (click on individual entry titles to see the header change).

If the first post on a page has no head_image custom field set the additional CSS line won’t be written and you’ll get the theme’s default image. The default settings are for the Benevolence theme/stylesheet but should be easy to modify to work with any style you’re using.

The source is available here. Copy this into a fresh headimage.php file, and make changes to the two defined variables if needed. Then upload it in your wp-content/plugins directory and activate the plugin.

Upload a header image into your /images directory (or whichever directory you’ve defined if you changed the variable) and then add a custom field to your entry with the key “head_image” and the value being the name of the header image file.

Update: I’ve updated the plugin to version 1.0 and it now works with Wordpress 2.1!


28 Responses to “HeadImage Wordpress Plugin”


  1. Gravatar Icon 1 Ozh Jan 27th, 2005 at 12:17 pm

    wow !! walter costinak ? The one from 2design ? The one who designs Bluesnews’ logos ?? Me drools, gonna check his blog right now :)

  2. Gravatar Icon 2 Puck Jan 28th, 2005 at 3:35 am

    That’s the one. He’s been a friend and mentor for ages, and has always hummed and hawed about making a blog and finally asked me to set one up for him. He’s enjoying it so far, I think.

  3. Gravatar Icon 3 Blips Feb 24th, 2005 at 9:05 pm

    Hi Puck.
    Just two comments while the idea is so great, its a shame. I like your solution.
    I’m looking for something you have build but then slightly different.
    I also like to change the banner when clicking on a post and bound to the category. In my case when talking about planes I want planes as a banne, when talking about the old days I want the old days as a banner, You get the drift.
    Then I do not find any reffernce to #masterhead in my theme, I have a theme installed that is doeing the header.jpg thur a CSS file. I’m not that familiar with CSS yet altough started to tweak with tryal and error.
    Feel free to take a peek at my blog. Oh did I told you its in Dutch :(
    Thanks.

  4. Gravatar Icon 4 Blips Feb 26th, 2005 at 1:18 pm

    Thanks for your (email) help it is working just great.

  5. Gravatar Icon 5 lars Mar 26th, 2005 at 5:49 am

    hello
    i´d like to integrate your plugin into my wordpress 1.5 site with kubrick as the default theme but with no success. can you help somehow in how to make it with kubrick?
    thanks.

  6. Gravatar Icon 6 Puck Mar 28th, 2005 at 12:26 am

    Lars — Kubrick is a little tricky as the top image includes whitespace, so be sure to include some of that in your image. Or modify the layout so it doesn’t use the whitespace…

    Kubrick also sets its images in the HTML of the Theme and not the CSS. He claims this is to accomodate differing install paths, but I don’t see any reason for this to be required.

    That said, the CSS element you need to be setting is called “#headerimg” in Kubrick. Change the plugin’s $headerstyle = “#masthead” line to $headerstyle = “#headerimg” and it should work fine.

  7. Gravatar Icon 7 Lars Ehlers May 24th, 2005 at 2:34 am

    hello puck,

    thank you for your help and the plugin, i tried it with kubrick and got it working besides some troubles in the admin area. now i have integrated it into another page and another theme without problems. thank you

  8. Gravatar Icon 8 Johan Jan 12th, 2006 at 4:42 pm

    Hello Joe,

    I wanted to use the HeadImage plugin on my WordPress 2.0 install, but it appears that it is not compatible (it breaks the image upload functionality) any chance of an upgrade?

    By the way, the download is broken, found the code using Google cache.

  9. Gravatar Icon 9 Johan Jan 15th, 2006 at 9:24 am

    Sorry about this, but the plugin *does work* on WordPress 2.0. I just made a copy/paste mistake that broke the code…

    The download link is still broken b.t.w.

  10. Gravatar Icon 10 Puck Mar 10th, 2006 at 4:40 pm

    Download link reactivated. Sorry, I removed it when upgrading to WP2 and forgot to put it back.

  11. Gravatar Icon 11 florian Mar 30th, 2006 at 4:10 am

    Hi!

    First of all thank you for this plug-in….but I got some problems:

    In my css-style the header is:

    #header {
    height: 295px;
    background: url(images/header.jpg) no-repeat;
    position: relative;
    top: 0px;
    margin: 0px;
    margin-top: 0px;
    }

    So I changed $headerstyle = “#header” in the headimage.php.

    For testing reasons I wanted to change my header in my category webdesign, so I added the key “head_image” and the value “header2.jpg”…The link to this image is http://www.florian24.com/blog/wp-content/themes/flopsycho/images/header2.jpg

    The Problem is now, if I open the category “webdesign” no header image at all is shown, if i go back to the main page, the standard header is shown.

    I don´t know what´s wrong !!??

  12. Gravatar Icon 12 florian Mar 30th, 2006 at 5:08 am

    I managed it another way :-)

  13. Gravatar Icon 13 Garrett Jul 20th, 2006 at 7:55 am

    Does this plugin also change the header for pages and subpages? (I looked at Walter’s site but don’t see any pages).
    Thanks, Garrett

  14. Gravatar Icon 14 Puck Jul 20th, 2006 at 1:31 pm

    I haven’t tried it but it should, as long as you add the same Custom Field to the page.

  15. Gravatar Icon 15 Marcus Aug 8th, 2006 at 12:14 pm

    Hi there,

    I would like to use the plugin in the Theme “Wococo” (http://themes.wordpress.net/columns/3-columns/791/wucoco-three-column-0100/) but I can’t get it working.

    Please help me. I can’t figure out how to modify the code.

    Thanx
    Marcus

  16. Gravatar Icon 16 Puck Aug 8th, 2006 at 8:27 pm

    Change the line:
    $headerstyle = “#masthead”;

    to read:
    $headerstyle = “#header”;

    and it should work.

  17. Gravatar Icon 17 Vicent Nov 8th, 2006 at 12:56 pm

    Please! I need help!

    How I can modify the script in order that instead of getting the first post of the page, script gets the first post of a determined category?

    I only need to know how to indicate this on $post = $posts[0];

    Thank you in advance!

  18. Gravatar Icon 18 Marc Jan 16th, 2007 at 8:16 am

    Hey!

    I use the “Freshy”-Theme and I changed the variable to “#header”. Then I added a custom field to my entry with the key “head_image” and the name of the header image file. But when I open the category nothing changes…there is still the standard header. Can u help me? :-3

  1. 1 Blips… » Weblog gezicht Pingback on Feb 26th, 2005 at 1:15 pm
  2. 2 empdesign » Blog Archive » Plugins Wp Pingback on May 16th, 2005 at 8:39 am
  3. 3 Netlex News » Blog Archive » HeadImage Wordpress Plugin Pingback on May 20th, 2005 at 3:17 am
  4. 4 Northern-Web-Coders » HeadImage Pingback on Oct 19th, 2005 at 1:40 am
  5. 5 Der wilde Garten | Verschiedene Header Pingback on Jul 7th, 2006 at 7:29 am
  6. 6 Los Blog’s de la pagina de UiDoS » Plugins para WordPress Pingback on Dec 23rd, 2006 at 8:27 am
  7. 7 Profesor Blog » Los Mejores Plugins Para Worpress Pingback on Apr 14th, 2007 at 3:33 am
  8. 8 » Enchula tu Blog,Plugins Para Worpress Información Tecnología Internet y Gadgets Pingback on Jul 13th, 2007 at 8:54 pm
  9. 9 La Mansion » Blog Archive » Plugins Wordpress Pingback on May 16th, 2008 at 12:20 pm
  10. 10 282 plugins para WordPress (3ª parte de la F a la K) | Pichicola.com Pingback on Aug 11th, 2008 at 4:44 pm

Leave a Reply