• Skip to main content
  • Skip to forum navigation

StudioPress

  • Shop for Themes
  • My StudioPress

Forum navigation

  • Home
  • General Genesis Discussions
  • StudioPress Themes
  • Genesis Blocks
    • Genesis Blocks
    • Genesis Custom Blocks
  • Retired Themes
  • FAQs
  • Forum Rules
  • Internationalization and Translations
  • Forum Bugs and Suggestions
  • Forum Log In

Are You Using The WordPress Block Editor?

Genesis now offers plugins that help you build better sites faster with the WordPress block editor (Gutenberg). Try the feature-rich free versions of each plugin for yourself!

Genesis Blocks Genesis Custom Blocks

Possible to make Featured Image display as a background image?

Welcome!

These forums are for general discussion on WordPress and Genesis. Official support for StudioPress themes is offered exclusively at My StudioPress. Responses in this forum are not guaranteed. Please note that this forum will require a new username, separate from the one used for My.StudioPress.

Log In
Register Lost Password

Community Forums › Forums › Archived Forums › Design Tips and Tricks › Possible to make Featured Image display as a background image?

This topic is: not resolved

Tagged: background, featured image

  • This topic has 2 replies, 2 voices, and was last updated 11 years, 1 month ago by AVwordpress.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • January 12, 2014 at 2:47 pm #84812
    mattspaeth
    Member

    I am trying to make the Featured Image of a post display as a background image so I can use the background-size: cover CSS property to get it scale nicely. Is this possible? Since you can't pass variables to a stylesheet I am not sure how it could be done.

    The reason I want to do this is that I have banner images in other areas of the size using the background images and background-size: cover. The Featured Image on the posts looks good at full width but when you scale it down, it doesn't behave nicely like the background images do.

    January 12, 2014 at 2:57 pm #84815
    mattspaeth
    Member

    I just figured it out. It works great! Here it is in case anyone else wants to do it:

    // Add Post featured image as a background image above post title, single posts only 
    add_action( 'genesis_after_header', 'custom_before_post_image');
    function custom_before_post_image() {
     
      if ( is_page() ) return;
      if ( is_home() ) return;
    
    	if ( $image = genesis_get_image( 'format=url&size=post-image' ) ) {
    		printf( '<div class="post-featured-image"><div class="post-photo" style="background-image: url(%s);"></div></div>', $image );
    	}
    }
    October 8, 2014 at 5:58 pm #127167
    AVwordpress
    Member

    BRILLIANT!

    i've adapted this to be the background of entry-header, works great!

  • Author
    Posts
Viewing 3 posts - 1 through 3 (of 3 total)
  • The forum ‘Design Tips and Tricks’ is closed to new topics and replies.

CTA

Ready to get started? Create a site or shop for themes.

Create a site with WP EngineShop for Themes

Footer

StudioPress

© 2025 WPEngine, Inc.

Products
  • Create a Site with WP Engine
  • Shop for Themes
  • Theme Features
  • Get Started
  • Showcase
Company
  • Brand Assets
  • Terms of Service
  • Accptable Usse Policy
  • Privacy Policy
  • Refund Policy
  • Contact Us
Community
  • Find Developers
  • Forums
  • Facebook Group
  • #GenesisWP
  • Showcase
Resources
  • StudioPress Blog
  • Help & Documentation
  • FAQs
  • Code Snippets
  • Affiliates
Connect
  • StudioPress Live
  • StudioPress FM
  • Facebook
  • Twitter
  • Dribbble