I've attempted to add images to publish by choosing it in the media and placing it towards the publish. But while using the has_publish_thumbnail() function, I'm not obtaining the result not surprisingly. Can anybody let me know how you can fasten a file towards the publish and obtain the origin link to the attached file.

are you currently Simply using the has_post_thumbnail() function?

has_post_thumbnail() returns a boolean (True/False) value based on whether there is available a thumbnail for stated publish. You need to add the function: the_post_thumbnail() next. This is actually the code I personally use for publish pictures:

<?php 
if ( has_post_thumbnail() ) { // check if the post has a Post Thumbnail assigned to it.
    the_post_thumbnail(); // show the post's thumbnail
} 
?>