Aweber - Email Marketing Made Easy
Add a Full Screen Background Image in Thesis Photo by: spettacolopuro

Add a Full Screen Background Image in Thesis

November 16, 2010 · 52 comments

in Thesis

Thesis 1.x Notice: Thanks for reading this post! So, here's the deal. I wanted you to be aware that this post was written prior to the release of Thesis 2. So that means the instructions or other information provided applies specifically to Thesis 1.x and not the latest 2.x version. Thanks!

There are a bunch of jQuery plugins and standard HTML/CSS solutions out there for creating a full screen, or full page background image that will stretch the image to the full width of the browser window. So basically no matter what size the screen is, it will resize the image accordingly. Here are a few that I found while searching:

There are numerous variations for creating the full screen background image, depending on your needs. For example, you can have just a single image, a series of images that rotate, and also you could have content above the image or not. I was working on a website for a client and there was a need to have a series of full screen background images on the home page that rotate and have some content above the image.

I ended up going with bgStretcher, but now I had to make it work in Thesis.

When we talk about jQuery Plugins we aren’t talking about traditional WordPress type plugins. jQuery plugins need to get integrated into the site by adding the necessary code in the right places and referencing the required plugin file.

How to Add a Full Screen Background Image in Thesis

It doesn’t matter which method you use from the list above, and you may even find a different one you prefer, but the concept is the same. In fact, this is a great lesson about Thesis hooks and how to add pretty much any custom functionality or content. Once you understand the concept, you can integrate almost anything you want.

So, let’s take a look at this. We’re going to integrate this jQuery plugin to display a full page background image in Thesis.

Step 1: Download the script

You can visit the bgStretcher page to download the file you need. Specifically, you want the file called bgstretcher.js. Upload this file to a new folder inside your custom folder called “js”. So it will look like this: /wp-content/themes/thesis_x/custom/js. The file needs to be inside the ‘js’ folder.

Step 2: Add the Scripts

Add this to your custom_functions.php file:

function fullbg() {
if (is_front_page()) {
?>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.3/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript" src="<?php bloginfo('template_directory'); ?>/custom/js/bgstretcher.js"></script>
<script type="text/javascript">
	$(document).ready(function(){
        //  Initialize Backgound Stretcher	   
		$(document).bgStretcher({
			images: ['<?php bloginfo('template_directory'); ?>/custom/images/sample-1.jpg', '<?php bloginfo('template_directory'); ?>/custom/images/sample-2.jpg', '<?php bloginfo('template_directory'); ?>/custom/images/sample-3.jpg'],
			imageWidth: 1024, imageHeight: 768
		});
	});
</script>

<?php } }

add_action('thesis_hook_after_html','fullbg');

Here’s what’s happening with this:

  1. I’m using a WordPress conditional tag so that this only appears on the home page. You can either remove this, or modify it so that it shows up where you want.
  2. We’re loading the jQuery library (*** IMPORTANT – If you already have jQuery being loaded, there is no need to do it again.)
  3. I’m inserting this code toward the bottom of of the site by using the thesis_hook_after_html hook.
  4. We’re referencing the bgstretcher.js file. (If you’re using a different plugin, the concept will be the same.)

  5. We’re defining the path and filenames of the images. You can change the filenames to the actual filenames of your images.
  6. We’re applying some options (imageWidth:1024, imageHeight:768). You should check the instructions page for this plugin for additional options. In my case, I also added these options because I wanted a delay between each slide and also a transition speed: nextSlideDelay: 10000, slideShowSpeed: 1000,

Step 3: Upload Your Images

You will need to upload your images that are referenced in the above script to the images folder inside your custom folder.

Step 4: Add the CSS

You’re going to need to reference the css file supplied with this plugin. It’s called bgstretcher.css. You can either include this as a separate css file, which you will need reference in the head section of the site, or you can paste the contents into the custom.css file.

That should do it as far as adding the full screen background images

This is all you need to do in order to get the full page background images working. Now, if you want to add text above the image, you will just need to add this inside the custom.css file to the css selector that contains the content you want to appear above the image:

position: relative;
z-index: 2;

For example:

.custom .format_text {
      position: relative;
      z-index: 2;
}

Hopefully this all makes sense for you. If you have questions or something to add, feel free to leave a comment below.

Was this post helpful? Consider subscribing to my blog via RSS or

This Site Runs on the Thesis WordPress Theme

Thesis Theme thumbnail

If you're someone who doesn't understand a lot of PHP, HTML, or CSS, Thesis will give you a ton of functionality without having to alter any code. For the advanced user, Thesis has incredible customization possibilities via extensive hooks and filters. And with so many design options, you can use the template over and over and never have it look like the same site.

If you're more familiar with how websites work, you can use the fantastic Thesis User's Guide and world-class support forums to make more professional customizations than you ever thought possible. The theme is not only highly customizable, but it allows me to build sites with a much more targeted focus on monetization than ever before. You can find out more about Thesis below:

{ 51 comments… read them below or add one }

Rob November 18, 2010 at 3:10 am

Hi – I’ve got the full screen working beneath my site but I wanted the image to replace the body colour in Thesis. Is this possible? Thanks

Reply

Thesis-Blogs.com November 18, 2010 at 10:25 am

Hi Rob. Thanks for commenting. Good to hear you got this working. I wasn’t able to take a look at your site as there was no URL, but I believe you’re referring to the typical white background color of the main Thesis page. If this is the case, just add a background:none; to the element you want to remove the body color on. For example: #page { background:none; }. You’d add that to your custom.css file.

Reply

Deb December 11, 2010 at 3:26 pm

Hi,
I was able to get this wonderful script working, however I’ve lost the page contents behind the full screen image. I am a beginner at this so bear with me. Thanks and hope to hear from you soon!

Reply

Thesis-Blogs.com December 11, 2010 at 4:07 pm

Hi Deb, add this to your custom.css file:

.full_width > .page {
    background: none;
    position: relative;
    z-index: 1;

This will bring the content of your site to the top, above the background image. You will have to style your text so it looks right above that background image.

Thanks for commenting.

Reply

Dan December 13, 2010 at 10:25 pm

Hi,

I spent hours last night trying to debug a large assortment of issues I was having constructing a Thesis 1.8 squeeze page. I figured out most of the problems, but wanted in the end to have a background image that stretched effortlessly. After several more hours and experimenting with several half-baked solutions, your post came up and solved it all exactly as I needed. Thank you!

I am hoping you can help a relatively inexperienced CSS coder with what’s probably fairly basic. If you look at the site I’m working on (http://centralcoastpac.org), you’ll the jQuery resizer working flawlessly. (I too opted for bgStretcher.) However, you’ll also see that the box of content that is placed on top of the background image is out of position. I’ve tried working with both your code and the bgStretcher site’s code, but I’m not having any luck getting it positioned where I’d like it.

Preferably, the box of content would be centered on the whole page (and the page should be 100% of the browser window width), and with its top edge starting maybe a 1/3 of the way down from the top-most edge.

I do have the page in Thesis configured for full-width framework. But no matter what combination of relative and absolute positioning I’m trying, it’s not working. (As in the box doesn’t move at all).

Can you offer any CSS guidance on what I’m doing wrong?

You can find my CSS code here:
http://centralcoastpac.org/wp-content/themes/thesis_18/custom/custom.css

Many, many thanks.
Dan

Reply

Thesis-Blogs.com December 13, 2010 at 10:43 pm

Hiya Dan… I feel your pain here. I too have spend countless hours in the past while learning all about CSS and web design, but that’s sometimes the only way to learn. Anyway, I’m happy to hear you were able to get the background image working from this tutorial. To fix your layout issue, you could do something like this. Add this to your custom.css file:

.custom .full_width .page {
    width: auto;
}

As to making the background of that content area extend the full width of the browser window, you’ll need to add some additional css to the custom.css file. Something like this should do:

.custom #content_box {
    background: #e3e3e3;
    position: relative;
    z-index: 2;
}

.custom #box {
	background:none;
}

Hope that helps.

Reply

Dan December 13, 2010 at 10:46 pm

Awesome! Much closer. And thank you for such a fast (and friendly) reply.

If I could trouble you one last time…If you look at it now, it’s centered correctly. However, it pushed the image itself down below the content area. http://centralcoastpac.org

Same link from previous post to my CSS.

Dan

Reply

Thesis-Blogs.com December 13, 2010 at 10:55 pm

No problem. I had a look and I’m not seeing the image being pushed under the content. It’s definitely taking up the entire window size with the content over it. If you change the background to ‘none’ on .custom #content_box you’ll see the image takes up the full screen.

Reply

Dan December 13, 2010 at 11:00 pm

Oh, I see. Perfect. I saw the color showing but not the top part of the image, and didn’t look at the background value for that DIV. Removing it shows the image again.

Thanks again for all your help!

Reply

Thesis-Blogs.com December 13, 2010 at 11:05 pm

No problem man… Good luck with the site. ;-)

Reply

Pablo December 30, 2010 at 10:04 pm

Hi! I have not done a thing yet, but I would like to place this code using the Thesis OpenHook Plugin or am I still going to have visit the custom.css file specifically? Thanks in advance!

Reply

Thesis-Blogs.com December 30, 2010 at 10:16 pm

Hi Pablo. Well, a couple things. The OpenHook plugin doesn’t have anything to do with the custom.css file. You’re going to have to add the css to the custom.css file no matter what. The other thing is that you really don’t need to use the OpenHook plugin, but if you absolutely want to, you can copy the code above that I said to paste into the custom-functions.php file, and paste it into the “thesis_hook_after_html” section of the OpenHook plugin. But you’re going to have to edit the code to remove the function part because it isn’t designed to just be pasted into the OpenHook plugin.

Reply

pablo December 31, 2010 at 3:32 am

thank you very much for the quick reply I appreciated it makes a lot of sense

Reply

Mark January 28, 2011 at 9:13 pm

Ho there. I too am having the same issue in regards to the content being displayed behind the images. I have tried the script that you gave Deb into the custom.css file however still nothing. Anything else that I can try?

p.s. thank you so much for this great Blog by the way. Really awesome!

Reply

Thesis-Blogs.com January 28, 2011 at 10:28 pm

I had a look at your site and it seems that the background image is not showing up behind the content of the page, but rather below the main site container. Try this:

#bgstretcher img {
    position:absolute;
    top:0;
    left:0;
    z-index:-1;
}

Reply

Mark January 28, 2011 at 11:23 pm

Awesome. Thank you so much for that and getting back to me so soon. Do you have any tips on making the content background transparent? many thanks

Reply

Thesis-Blogs.com January 28, 2011 at 11:42 pm

just add

background:transparent;

to the container div in the custom.css file. I recommend you get Firebug.

Reply

Mark January 29, 2011 at 1:14 am

Awesome. You are a legend! :)

Reply

Tara Carreon June 20, 2011 at 2:17 pm

I did everything until I got to your Step 4: Add the CSS. You’re going to need to reference the css file supplied with this plugin. It’s called bgstretcher.css. You can either include this as a separate css file, which you will need reference in the head section of the site, or you can paste the contents into the custom.css file.

How do I reference this exactly. Can you give me the exact code to dump into the CSS? Thank you. I don’t know how to do anything except EXACTLY as you tell me. At step 4, you assumed I knew something I didn’t. Thank you.

Reply

Thesis-Blogs.com June 20, 2011 at 10:08 pm

Sure, here’s a function you can add to your custom_functions.php file which will place the reference to the css file in the head section of the site:

function bgstretcher_css() {
?>
	<link rel="stylesheet" type="text/css" href="<?php bloginfo('template_directory'); ?>/custom/bgstretcher.css" />
<?php
}

add_action('wp_head','bgstretcher_css');

This is a good lesson on how to use hooks. In this case, we’re just using a standard WordPress hook, but it works the same with Thesis Hooks.

Reply

Matt July 20, 2011 at 8:04 am

Hi, thanks for the quick and well explained tutorial. Any idea if bgStrectch supports the WordPress 3 Custom Menu System? or know how I would go about finding out? More specifically, I am using Uber Menu wp mega menu plugin and hoped to use Gecka bgStrecher also for background image slider. Wonder if they’re compatable? Thanks, Matt

Reply

Thesis-Blogs.com July 20, 2011 at 8:52 am

Well, the background should have no connect to the menu system. You shouldn’t have any problems running them both.

Reply

Greg Pfeffer July 23, 2011 at 6:10 am

Hey Guys,
Total thesis/PHP newbie here. Where in custom_functions.php do I insert the code? I tried a few places and I just break my site. Thanks!

-Greg

Reply

Thesis-Blogs.com July 23, 2011 at 9:51 am

There is usually some commented text showing you where to paste your functions, but it’s after where you see <?php at the very top of the file and before ?> where it’s closed at the very end of the file. Thanks for commenting.

Reply

Dave August 8, 2011 at 11:03 am

Great Tutorial, thanks for the code!

I am also having the “content not showing” up problem. I tried adding both the CSS you gave to to Deb and Mark to no avail.

Dave

Reply

Thesis-Blogs.com August 8, 2011 at 7:43 pm

I had a look at your site and don’t see any content in the code that isn’t displaying. All you have is that video. What is supposed to show up that isn’t? Also, if you don’t need a rotating image, you could take the simpler route and use the css3 way with background-size property. You can read more about that here. It’s the first example.

Reply

Jeremy November 5, 2011 at 2:15 pm

Hi there

Brilliant tutorial and script. Unfortunately I have the same problem as others as I cannot see content. I have tried the above fixes to no avail. Any help greatly appreciated. Also you mention that if you use one image for background that you should follow a different tutorial. As I have this working (almost :) ) why would I go that route. Thanks for your. help

Reply

Thesis-Blogs.com November 5, 2011 at 10:45 pm

Add this to your custom.css file:

.custom #container {
    position: relative;
    z-index: 2;
}

.custom #page {
    background: transparent;
}

This will bring the content above the image. Of course, you are also going to have to style your content so that it looks good over an image background. Don’t use the #page part if you just want to leave the standard white page background.

As to why you’d use the other method for displaying a single image full screen using css, it’s just easier and quicker to implement. Use either method.

Reply

Jeremy November 6, 2011 at 10:11 am

Thanks so much. It works like a dream. One more question – the image I have is to big. It is 2716-1810 . on your settings I have imageWidth: 1024, imageHeight: 768

However I change the size of the image, when I look on the website the image does not shrink at all. What can I do to see the whole image on the site and not cut off the bottom?

Reply

Rob January 24, 2012 at 10:27 pm

Hi There,

I loved your tutorial, however, I can not get the background image to display at all.

I am a complete Newb, I mean like right out of the womb, this is the first time ever I have coded anything. CSS or otherwise. So I REALLY REALLY REALLY appreciate any help I can get, I tried for 3 hours before I broke down and sent this message. Anything you can help me with would be greatly appreciated. Not sure where I am going wrong.

Reply

Thesis-Blogs.com January 25, 2012 at 8:32 am

Can’t help you unless I see the site you’re trying to get it to work on.

Reply

Rob January 26, 2012 at 8:46 pm

Just wanted to say thanks so much Paul. Your patience and advice for this newb was extremely appreciated and helpful. Great tutorial!

Reply

Thesis-Blogs.com January 26, 2012 at 9:04 pm

No problem! Pleased to help where I can.

Reply

Fay February 3, 2012 at 9:48 pm

Great tutorial…but I’ve been trying to implement it for a couple of hours now and am totally frustrated. I’m almost jealous of the folks whose content is covered by their images! My background images just aren’t showing. Would LOVE it if you would have a look and tell me where I’ve gone awry. fayratta.com.

Thanks!!
Fay recently posted..A Fall Good Ol’ Fun Trip

Reply

Thesis-Blogs.com February 4, 2012 at 9:14 am

Looks like you’re loading jQuery and bgstretcher twice. That may have something to do with it.

Reply

Fay February 4, 2012 at 10:06 am

Alas, no. Found the other instances and ditched them but still no image. I also took off the conditional bit you had to apply it only to the home page, but no luck.

Also, for some reason Dreamweaver is giving me an error on the php code, but it loads just fine in the “custom file editor”. It doesn’t say what the error is, but highlights the 2 ‘add_actions’ at the end. Anything stick out there to you?
Fay recently posted..A Fall Good Ol’ Fun Trip

Reply

Thesis-Blogs.com February 4, 2012 at 10:12 am

Look at the code of the rendered page in the browser. Your image URL is wrong. Try fix that.

Reply

Jim May 7, 2012 at 4:11 pm

Can you please look at this and tell me why background isn’t showing up.
Ty, Jim
Jim recently posted..Hello world!

Reply

Thesis-Blogs.com May 7, 2012 at 4:15 pm

Check to make sure the bgstretcher.js file is located in the js folder as indicated in the post. It looks like it isn’t on your site.

Reply

Jim May 7, 2012 at 4:29 pm

Ty again…I put the js folder in the images folder and didn’t notice it.
Jim recently posted..Hello world!

Reply

Jim May 7, 2012 at 4:31 pm

Also thanks for the quick response, I wish everyone was as good as you in responding to questions!
Jim recently posted..Hello world!

Reply

Thesis-Blogs.com May 7, 2012 at 6:02 pm

No problem. It looks like you got it working.

Reply

Jim May 8, 2012 at 7:55 am

Hi, this is what is in my css file, but I don’t see any content text?
Please help.

.bgstretcher {
	background: black;
	overflow: hidden;
	width: 100%;
	position: fixed !important;
	z-index: 1;
}
.bgstretcher, .bgstretcher UL, .bgstretcher UL LI {
	position: absolute;
	top: 0;
	right: 0;
	left: 0;
	bottom: 0;
}
.bgstretcher UL, .bgstretcher UL LI {
	margin: 0;
	padding: 0;
	list-style: none;
}
#page { background:none; }

Jim recently posted..Hello world!

Reply

Thesis-Blogs.com May 8, 2012 at 9:29 am
Jim May 8, 2012 at 9:39 am

I have tried it and nothing. Can you please look and see what you think.
Jim recently posted..Hello world!

Reply

Thesis-Blogs.com May 8, 2012 at 12:51 pm

I just looked at your site, and the text is there. So perhaps you figured it out.

Reply

Glenn Sojourner May 13, 2012 at 9:29 pm

Hi…installed bgStretcher and I have installed the script twice and made the changes recommended to others to show my header and content but I am not getting anywhere. The one thing that does show is my menu.

Any advice?

Thanks,
Glenn
Glenn Sojourner recently posted..Hello world!

Reply

Thesis-Blogs.com May 14, 2012 at 3:13 pm

Add this to your custom.css file:

.custom #content_box {
    position: relative;
    z-index: 2;
}

Reply

Chris May 22, 2012 at 5:24 pm

One of the best and most valuable thesis tutorials I’ve seen. Thank you!

Reply

Thesis-Blogs.com May 22, 2012 at 5:31 pm

Great, thanks!

Reply

Chris May 22, 2012 at 8:23 pm

A question: Is it possible to make the images scroll?

Reply

Leave a Comment

When commenting, you can use basic HTML tags. If you are pasting in any code, please escape it here and then include that code within <pre></pre> tags. Thanks!

CommentLuv badge

{ 1 trackback }

Previous post:

Next post: