How to Get Comment Post İmage

  html, javascript, php, woocommerce, wordpress

I have a review showcase I tried a little bit to automate it everything works fine but I can’t get the image of the product under review I’ve done everything successfully but I can’t do it.

get the image of the product under review that I’m trying to do my codes;

<div class="testimonial-active owl-carousel">

                                    <?php foreach ($comments as $comment) : ?>
                                        <div class="testimonial-item">
                                            <div class="testimonial-content mb-40">
                                                <h5><?php echo get_the_title($comment->comment_post_ID); ?></h5>
                                                
                                                <?php geco_star_rating(['rating' => 5, 'class' => 'testimonial-rating mb-30']); ?>
                                                <p>“ <?php echo $comment->comment_content; ?> ”</p>

                                            </div>
                                            <div class="testimonial-avatar">
                                                <div class="testi-avtar-img">
                                                
                                                    //HERE <img src="<?php echo wp_get_attachment_image_src(get_post_thumbnail_id($comment->comment_post_ID), 'thumbnail'); ?>" alt="<?php echo esc_attr($item['author']); ?>">
                                                </div>
                                                <div class="testi-avatar-info">
                                                    <h6><?php echo $comment->comment_author ?></h6>
                                                    <span><?php echo esc_html("sdasdasd"); ?></span>
                                                </div>
                                            </div>
                                        </div>
                                    <?php endforeach; ?>

                                </div>

I tried this way, I don’t get an error, but the image does not appear;

<img src="<?php echo wp_get_attachment_image_src(get_post_thumbnail_id($comment->comment_post_ID), 'thumbnail'); ?>" alt="<?php echo esc_attr($item['author']); ?>">

Source: Ask PHP

LEAVE A COMMENT