Skip to content

Instantly share code, notes, and snippets.

@bueltge
Created June 14, 2012 12:41
Show Gist options
  • Star 16 You must be signed in to star a gist
  • Fork 5 You must be signed in to fork a gist
  • Save bueltge/2930032 to your computer and use it in GitHub Desktop.
Save bueltge/2930032 to your computer and use it in GitHub Desktop.
Set featureed image automaticly on save post/page
@rpgmem
Copy link

rpgmem commented Jan 12, 2013

@bueltge
Very good solution! Works great, however I would like to know more how to implement a function to this script:
I would like if there were no images attached to the post, a standard image set to be featured image.

Tks!

@bueltge
Copy link
Author

bueltge commented Jan 24, 2013

If you will add a default image, if you have no uploaded image on the post, use the source bellow.

add_filter( 'post_thumbnail_html', 'fb_post_thumbnail_html' );
function fb_post_thumbnail_html( $html ) {

    if ( empty( $html ) )
        $html = '<img src="' . trailingslashit( get_stylesheet_directory_uri() ) . 'images/default-thumbnail.png' . '" alt="" />';

    return $html;
}

@rpgmem
Copy link

rpgmem commented Feb 1, 2013

Sorry, but how implement this code?
Should I replace or include it in which lines of the original code?

@bueltge
Copy link
Author

bueltge commented Feb 11, 2013

@rpgmen: add this lines from my comment to the plugin, below all source, the init source and ready.

@saiallexander
Copy link

How to modify to support custom post type? for example I have custom post type 'property'

@duenner
Copy link

duenner commented Sep 4, 2013

Bin ich nur zu blöd, dass ich den Download-Button nicht sehe? Wie kriege ich das Plugin sonst runter? Vielen Dank für eure Hilfe.

@casepress
Copy link

Maybe you public this plugin to WordPress repository?

@rpgmem
Copy link

rpgmem commented May 5, 2014

@bueltge Strangely complement the script stopped working in the last version of WP ... the standard image that no longer appear when the post is saved ... could check the reason?

@tuba82
Copy link

tuba82 commented Dec 8, 2015

hello @bueltge I editliy my themes the component files individually. The markings on the slider component files: How do I bring small areas?http://prntscr.com/9bxbx4

@dragipostolovski
Copy link

so unhelpful and waste of time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment