Changed the logic for attaching image for publication.

 Changed the logic for attaching image for publication.