I have the URL of my image and I want to display the thumbnail of that image. Is this possible. I check the_post_thumbnail() function but I can’t add the URL of the image as an input.

1 Answer
1

Get the image ID from the URL with attachment_url_to_postid():

$image_id   = attachment_url_to_postid( $image_url ); 

Convert the ID to the thumbnail image URL with wp_get_attachment_image_src:

$thumbnail_url = wp_get_attachment_image_src( $image_id, 'thumbnail' );

Leave a Reply

Your email address will not be published. Required fields are marked *