Is the image only apply to a single post? (as for other case like category page, there is a number of posts that may have different images)
If in this case (only for a single post), I suggest to add something like the followings into the single.php inside the loop:
<?php
$imageName = get_post_meta($post->ID, "CustomFieldNameForTheImage", true);
if($imageName != '') { ?>
<style type="text/css">
body { background-image:url(<?php bloginfo('template_directory'); ?>/uploads/<?php echo $imageName ?>.jpg);background-repeat:repeat;); }
<?php
}
?>
The problem is that style tag inside body will cause validating error.
You can also have several post-templates, styled differently. This option will make you work faster with less custom fields to worry about. And you will pass validation.
assuming the you have the absolute path to your image in your custom field, and the custom field key is ‘post_background’, and your post is in a div with the class .post, and that you have set the default or other background properties in style.css; you could try something like this:
<?php $bg_img = get_post_meta($post->ID,'post_background',true); ?>
<div class="post"<?php if($bg_img != '') { echo ' style="background-image: url(' . $bg_img . '); "' ; } ?>>
<!-- your usual code to show the title, posts, postmetadat etc -->
</div>
Thanks for your input guys.
Basically its for a portfolio site and each time you go onto a post or page they want the background body image to change to a big photo of their work, with the post content textual etc over the top..
Thats the gist of it…