How to require post thumbnails.?

I use a custom post type, and would like to make the thumbnail required for end-users.

Does anyone know how to make thumbnails required..?

  • Hjalde Markvad
    • Flash Drive

    Hmm, if you just have the right words, google is your best friend..

    Found a code snippet to automatically set the featured image, if anyone needs it, and it works perfekt for me so far..

    /** Automatically set the featured image */
    add_action('the_post', 'hm_autoset_featured');
    add_action('save_post', 'hm_autoset_featured');
    add_action('draft_to_publish', 'hm_autoset_featured');
    add_action('new_to_publish', 'hm_autoset_featured');
    add_action('pending_to_publish', 'hm_autoset_featured');
    add_action('future_to_publish', 'hm_autoset_featured');

    function hm_autoset_featured() {
    global $post;
    $already_has_thumb = has_post_thumbnail($post->ID);
    if (!$already_has_thumb) {
    $attached_image = get_children( "post_parent=$post->ID&post_type=attachment&post_mime_type=image&numberposts=1" );
    if ($attached_image) {
    foreach ($attached_image as $attachment_id => $attachment) {
    set_post_thumbnail($post->ID, $attachment_id);
    }
    }
    }
    }

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.