• 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

Define a default feature image when non available for Featured post widgets?

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 › Define a default feature image when non available for Featured post widgets?

This topic is: not resolved

Tagged: Feature Post Widget, featured posts images, genesis

  • This topic has 6 replies, 4 voices, and was last updated 8 years, 9 months ago by Genesis Developer.
Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • February 14, 2014 at 3:05 pm #90350
    hobbygirl66
    Member

    I often make posst on the fly using my smartphone. I don't have time or means to create a feature image every time.
    I do love the featured post/page type widgets on my home page and need an image for the widget to diplay properly on my home page. Is there a way to assign a default image to use in Featured post/page type widgets when there is not an image within the post/page on publication?
    So I would have a generic "tips and tricks" type graphic or similar pop in when no feature image attached to post.

    Thanks!
    Lisa

    April 14, 2014 at 9:21 am #100205
    Susan
    Moderator

    As you posted this a while back, I hope you were able to get your issue resolved. If not, please check back in here, and I will escalate for you.

    If it is resolved, please mark the thread “resolved”, and I will close it.

    Thanks!

    April 22, 2014 at 4:01 am #101821
    francky
    Member

    Hi Susan!

    I would also like to get the solution to this. I'm looking for the same stuff too.

    Thank you in advance.

    April 22, 2014 at 7:35 am #101847
    Genesis Developer
    Member

    Try this code

    /** Define a default post thumbnail */
    add_filter('genesis_get_image', 'default_image_fallback', 10, 2);
    function default_image_fallback($output, $args) {
        global $post;
        if( $output || $args['size'] == 'full' )
            return $output;
     
        $thumbnail = CHILD_URL.'/images/thumb.jpg';
     
        switch($args['format']) {
     
            case 'html' :
                return '<img src="'.$thumbnail.'" class="attachment-'. $args['size'] .'" alt="'. get_the_title($post->ID) .'" />';
                break;
            case 'url' :
                return $thumbnail;
                break;
           default :
               return $output;
                break;
        }
    }

    Download Genesis Featured Posts Combo Widget | Simple Grid Layouts Plugin for Posts, CPTs and terms
    You can request new tips/help.

    April 22, 2014 at 11:00 am #101888
    francky
    Member

    Thank you @genwrock

    Does that work for the Featured Post Widget only or for the whole site?

    I got another solution here http://sridharkatakam.com/set-default-image-genesis-featured-posts-widget/ but would like to change the alt "Default Featured Images" to post title like you've done there. Can you help?

    Shall appreciate it, Sir!

    April 22, 2014 at 11:15 am #101892
    Genesis Developer
    Member

    My code will work on whole site


    Download Genesis Featured Posts Combo Widget | Simple Grid Layouts Plugin for Posts, CPTs and terms
    You can request new tips/help.

    April 22, 2014 at 11:15 am #101893
    Genesis Developer
    Member

    I got the code from here http://genesissnippets.com/define-default-post-thumbnail/


    Download Genesis Featured Posts Combo Widget | Simple Grid Layouts Plugin for Posts, CPTs and terms
    You can request new tips/help.

  • Author
    Posts
Viewing 7 posts - 1 through 7 (of 7 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

© 2023 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