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:
- bgStretcher
- Perfect Full Page Background Image
- Effortless Full Screen Background Images With jQuery
- Supersized – Full Screen Background/Slideshow jQuery Plugin
- Resizable full-browser background image with jQuery (preserving aspect ratio)
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:
- 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.
- We’re loading the jQuery library (*** IMPORTANT – If you already have jQuery being loaded, there is no need to do it again.)
- I’m inserting this code toward the bottom of of the site by using the
thesis_hook_after_htmlhook. - We’re referencing the
bgstretcher.jsfile. (If you’re using a different plugin, the concept will be the same.) - We’re defining the path and filenames of the images. You can change the filenames to the actual filenames of your images.
- 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








































{ 51 comments… read them below or add one }
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
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 yourcustom.cssfile.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!
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.
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
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.cssfile:.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.cssfile. Something like this should do:.custom #content_box { background: #e3e3e3; position: relative; z-index: 2; } .custom #box { background:none; }Hope that helps.
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
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_boxyou’ll see the image takes up the full screen.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!
No problem man… Good luck with the site.
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!
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.
thank you very much for the quick reply I appreciated it makes a lot of sense
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!
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; }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
just add
to the container div in the custom.css file. I recommend you get Firebug.
Awesome. You are a legend!
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.
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.
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
Well, the background should have no connect to the menu system. You shouldn’t have any problems running them both.
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
There is usually some commented text showing you where to paste your functions, but it’s after where you see
<?phpat the very top of the file and before?>where it’s closed at the very end of the file. Thanks for commenting.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
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.
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
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.
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?
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.
Can’t help you unless I see the site you’re trying to get it to work on.
Just wanted to say thanks so much Paul. Your patience and advice for this newb was extremely appreciated and helpful. Great tutorial!
No problem! Pleased to help where I can.
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
Looks like you’re loading jQuery and bgstretcher twice. That may have something to do with it.
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
Look at the code of the rendered page in the browser. Your image URL is wrong. Try fix that.
Can you please look at this and tell me why background isn’t showing up.
Ty, Jim
Jim recently posted..Hello world!
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.
Ty again…I put the js folder in the images folder and didn’t notice it.
Jim recently posted..Hello world!
Also thanks for the quick response, I wish everyone was as good as you in responding to questions!
Jim recently posted..Hello world!
No problem. It looks like you got it working.
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!
Refer to this comment above:
http://thesis-blogs.com/add-a-full-screen-background-image-in-thesis/comment-page-1/#comment-2024
I have tried it and nothing. Can you please look and see what you think.
Jim recently posted..Hello world!
I just looked at your site, and the text is there. So perhaps you figured it out.
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!
Add this to your custom.css file:
.custom #content_box { position: relative; z-index: 2; }One of the best and most valuable thesis tutorials I’ve seen. Thank you!
Great, thanks!
A question: Is it possible to make the images scroll?
{ 1 trackback }