Spaces must be put around `!`, as per the [styleguide](http://ellislab.com/codeigniter/user-guide/general/styleguide.html); use single quotes.

However, simply inverting the order makes it shorter and looks nicer:

    .(empty($this->_attachments[$i]['cid']) ? '' : <rest of the code>