Оберните div вокруг каждого img внутри .post:
$('.post img').wrap('<div class="wrapper" />');
Оберните div вокруг каждого сообщения с img:
$('.post:has(img)').wrap('<div class="wrapper" />');
Переместите все div, имеющие imgвнутри оболочки div:
$('<div class="wrapper" />').append($('.post:has(img)'));