JSFiddle - React, Tailwind, and code Playground
HTML
<div class="post_body">
<!--IMG z ahref-->
<a href="http://i.imgur.com/lmaJG.jpg" class="lightview limg"><img src="http://i.imgur.com/lmaJGl.jpg" alt=""/></a>
<!--IMG bez ahref-->
<img src="http://placekitten.com/200/300" alt="bez href"/>
</div>
CSS
.post_body img {max-width:200px;max-height:200px;}
.post_body .limg {background-color:blue;}
JavaScript
$('div.post_body').each(function() {
$(this).find('img').each(function () {
var img = $(this);
if (img.is('a') !== true) {
img.wrap(
$('<a/>').attr('href', img.attr('src')).addClass('lightview limg');
);
}
));
});