After self-study, I know how to get the url image in the comment with the following code, this code put in the functions.php file.
functions.php:
function get_attachment_url_image_comment($comment_id) {
$meta_key = 'attachment_id';
$attachment_id = get_comment_meta( $comment_id, $meta_key, true );
$full_img_url = wp_get_attachment_image_url( $attachment_id, 'full' );
return $full_img_url;
}
view:
<?php $comments = get_comments($param) ?>
<?php foreach($comments as $comment): ?>
echo get_attachment_url_image_comment($comment->comment_ID);
<?php endforeach; ?>
It works fine!
(@hoangemini)
2 years, 6 months ago
How can I get a link to an image that’s embedded in a comment by getting a list of comments?
Thank everyone!