Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm attempting to use the 'feature image' feature of Wordpress to make a full screen background, that resizes to fit the browser window using jQuery

The bit I'm stuck on is adding a custom id (#bgimg) to the code generated by this:

<div class="background"><?php the_post_thumbnail (array(1024,768));?></div>

The image generated needs to have specific id tag in it, eg...

<img id="bgimg" src="wordpress/generated/etc.jpg">

So that the jQuery plugin, can hook on to it, and scale it to fit the browser window. I know the jQuery works (as I've used it in other projects)

Any suggestions? Alex

share|improve this question

1 Answer 1

up vote 2 down vote accepted

Use get_the_post_thumbnail() instead. It allows you to pass in an array of attributes for the image tag that gets returned.

For example:

$attr = array(
    'id' => 'YOUR-UNIQUE-ID',
);

echo get_the_post_thumbnail( $id, 'thumbnail', $attr );

EDIT:

I'm dumb. the_post_thumbnail() also lets you do that. Try passing the same args array I outlined as the second param.

share|improve this answer
    
Thanks MathSmath, Fixed it up a treat. –  Alex Dec 16 '10 at 2:08

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.