WordPress.org

Ready to get started?Download WordPress

Forums

Using Featured Image as background art... need diff image for thumbnail? (3 posts)

  1. jasonsherwin
    Member
    Posted 3 years ago #

    Hey Guys,

    So I'm using the new 'featured image' feature to specify alternate background art for some pages.

    I also would like to have thumbnails for these pages with different artwork. And I don't want either of these images to show up when I pull all the images uploaded for that page to use as a gallery on the page.

    I can't think of any clean way to achieve this...

    It's easy to exclude the featured image from these gallery results... but what about the thumbnail image?

    I'd prefer not to modify the db...

    Any thoughts?

  2. Digital Raindrops
    Member
    Posted 3 years ago #

    How about using a page or post custom field 'bg_image_url' for the background images, upload the images in the media section so they are not associated with the post. Copy the image url and save it in a custom field.

    Then just set this in the header.php file.

    <?php $pagebg = htmlspecialchars( get_post_meta( $post->ID, 'bg_image_url', true )); ?>
    
    <?php if($pagebg) : ?>
       <body style="background-image: url('<?php echo $pagebg; ?>')">
    <?php else : ?>
    <body <?php body_class(); ?>>
    <?php endif; ?>

    Untested code but should work!

    David

  3. jasonsherwin
    Member
    Posted 3 years ago #

    Hey Adeptris,

    Thanks for the tip.

    I played around with this a bit earlier but ended up going with this awesome cms plugin called magic fields instead:
    http://wordpress.org/extend/plugins/magic-fields/

    If it was gonna just be me updating the site I'd have gone with your solution above and avoided using a huge plugin for something like this... But this stuff's gotta be super simple and straighforward on the backend... the less steps the better!

    This plugin gives them 2 pretty upload forms so it's quick and easy.

    thanks again,

    -jason

Topic Closed

This topic has been closed to new replies.

About this Topic