[ticket/289] Removed duplicated code from attachments.php

Fixes #289