ID ); $exclude_types = array( '' ); $exclude_types = apply_filters( 'eat_exclude_types', $exclude_types ); // do nothing if the post has already a featured image set if ( $already_has_thumb ) { return; } // do the job if the post is not from an excluded type if ( ! in_array( $post_type, $exclude_types ) ) { // get first attached image $img = rv_auto_featured_image_catch_that_image( $post ); $attachment_id = attachment_url_to_postid( $img ); if ( $attachment_id ) { // add attachment ID add_post_meta( $post->ID, '_thumbnail_id', $attachment_id, true ); } } } // set featured image before post is displayed (for old posts) add_action( 'the_post', 'rv_auto_featured_image_add_thumbnail' ); // hooks added to set the thumbnail when publishing too add_action( 'new_to_publish', 'rv_auto_featured_image_add_thumbnail' ); add_action( 'draft_to_publish', 'rv_auto_featured_image_add_thumbnail' ); add_action( 'pending_to_publish', 'rv_auto_featured_image_add_thumbnail' ); add_action( 'future_to_publish', 'rv_auto_featured_image_add_thumbnail' ); function rv_auto_featured_image_catch_that_image( $post ) { // Find the images in the post_content. $output = preg_match_all( '//i', $post->post_content, $matches ); $first_img = isset( $matches[1][0] ) ? $matches[1][0]:''; // if no images found, do nothing if ( empty ( $first_img ) ) { return false; } return $first_img; } }China – Tripadorn
Discovering the Giant Buddha of Leshan

Discovering the Giant Buddha of Leshan

Located in the heart of China, through impenetrable forests, towering peaks, rolling hills and breath-taking valleys carved by the Yangtze river is the province of Sichuan. This province is seen as one... Read more »
Ad Widget
Beijing | 10 Ways to Get Lost in the Heart of China

Beijing | 10 Ways to Get Lost in the Heart of China

In many ways, Beijing is China. So much of the way people perceive the Middle Kingdom is wrapped up in the Chinese capital, and with good reason. You’ll find history dating back... Read more »
Zhangjiajie | A Guide to the Realm of Karsts and Clouds

Zhangjiajie | A Guide to the Realm of Karsts and Clouds

Famous as the land that inspired James Cameron’s Avatar, Zhangjiajie in Hunan Province, China, truly lives up to its otherworldly reputation. With gorgeous views and unique experiences to spare, the mountainous region... Read more »
Shanghai | Top Attractions of the World’s Largest City

Shanghai | Top Attractions of the World’s Largest City

Like Beijing and Hong Kong, Shanghai often serves as a gateway to travels in the Middle Kingdom. It’s easy to see why. With plentiful English and an international vibe, Shanghai is a... Read more »
A note to our visitors

This website has updated its privacy policy in compliance with changes to European Union data protection law, for all members globally. We’ve also updated our Privacy Policy to give you more information about your rights and responsibilities with respect to your privacy and personal information. Please read this to review the updates about which cookies we use and what information we collect on our site. By continuing to use this site, you are agreeing to our updated privacy policy.