0

I am trying to set the featured image (webp) from post content to automatically set as featured with the following code in functions.php

Auto add featured image function
wpsites_auto_set_featured_image() {    global $post;   
$featured_image_exists = has_post_thumbnail($post->ID);
      if (!$featured_image_exists)  {
         $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);}
         }
      } } add_action('the_post', 'wpsites_auto_set_featured_image');

Also the plugin Quick Featured Images stopped working after changed my images to .webp format. Is there any solution in WordPress to add automatic thumbnails that support webp format?

Thank you in advance Gregory

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.