Wordpress 精选缩略图图片链接出错

Wordpress Feautured Thumbnail Image Linking Gone wrong

我做错了什么?该图像根本没有列出,就像媒体库中没有图像一样,当我更改 id 时,它会列出所有图像,但我只需要一个。 你能帮帮我吗?

<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
        <div class="post-masonry col-md-4 col-sm-6 wow fadeInUp ">    
        <div class="blog-wrapper" <?php echo post_class(); ?> >    
        <?php $featuredImage = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'medium' );  ?>    
             <img src="<?php echo $featuredImage[0]; ?>" class="img-responsive">
             <h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
             <small><?php the_time('F jS, Y'); ?></small>
             <p><?php the_excerpt(); ?></p>
         </div>
    </div>
<?php endwhile; else: ?>
    <h3>No posts in database </h3>
<?php endif; ?>

到目前为止我已经尝试了所有可能的功能:wp_get_attachment_url、wp_get_attachment_image、wp_get_attachment_image_src、wp_get_attachment...

嗯,我设法得到了我想要的,但我仍然没有弄清楚为什么它不显示使用这些功能的图像...

这是一个自定义函数,它选择 post...

中的第一张图片
function catch_that_image() {
    global $post, $posts;
    $first_img = "get_stylesheet_directory_uri().";
    ob_start();
    ob_end_clean();
    $output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $post->post_content, $matches);
    $first_img = $matches [1] [0];

    if(empty($first_img)){ //Defines a default image
        $first_img = '';
}
    return $first_img;
}