/**
  * @param Open_Gallery_Model_Item $item
  * @param Mage_Adminhtml_Controller_Action $controller
  * @return $this|Open_Gallery_Helper_Item_Interface
  * @throws Exception
  * @throws Mage_Core_Exception
  * @throws Open_Gallery_Exception
  */
 public function prepareItemSave(Open_Gallery_Model_Item $item, Mage_Adminhtml_Controller_Action $controller)
 {
     $data = $controller->getRequest()->getPost('item');
     if (isset($data['thumbnail'], $data['thumbnail']['delete']) && !empty($data['thumbnail']['delete'])) {
         $item->deleteThumbnail();
         $item->setData('thumbnail', '');
     } else {
         if (isset($_FILES['item']['tmp_name']['thumbnail']) && $_FILES['item']['tmp_name']['thumbnail']) {
             try {
                 $savedFilePath = $this->_saveFile('item[thumbnail]', array('jpg', 'jpeg', 'png', 'gif'), 'thumbnail');
                 $item->setData('thumbnail', $savedFilePath);
             } catch (Mage_Core_Exception $e) {
                 throw $e;
             } catch (Exception $e) {
                 Mage::logException($e);
                 throw new Open_Gallery_Exception($this->__("Can't save thumbnail."));
             }
         }
     }
     unset($data['thumbnail'], $data['value']);
     $item->addData($data);
     return $this;
 }