public function doSaveMedia($v)
 {
     if ($v == null) {
         $image = $this->getImagePath();
         if ($this->isNew) {
             $content = file_get_contents(sfConfig::get('sf_root_dir') . '/public_html' . $image);
             $size = getimagesize(sfConfig::get('sf_root_dir') . '/public_html' . $image);
         } else {
             return $this->getObject()->getImagesId();
         }
     } else {
         $content = file_get_contents($v->getTempName());
         $size = getimagesize($v->getTempName());
     }
     $hash = md5($content);
     $criteria = new Criteria();
     $criteria->add(ImagesPeer::CONTENT_HASH, $hash);
     $obj = ImagesPeer::doSelectOne($criteria);
     try {
         if (empty($obj)) {
             $obj = new Images();
             $obj->setNameDownloadedFile($v->getOriginalName())->setNameFileForPage($v->getOriginalName())->setTypeImg($v->getType())->setHeight($size[2])->setWidth($size[1])->setContentHash($hash . '.jpg')->setContent(base64_encode($content))->setCreatedAt(date("Y-m-d H:i"))->setUpdatedAt(date("Y-m-d H:i"))->save();
         }
     } catch (Exception $e) {
         echo "stdfdfdfdfrt";
         die;
     }
     $criteria = new Criteria();
     $criteria->add(ImagesPeer::CONTENT_HASH, $obj->getContentHash());
     $obj = ImagesPeer::doSelectOne($criteria);
     return $obj->getId();
 }
 public function doSaveMedia($v)
 {
     //var_dump($v);die;
     $content = file_get_contents($v['tmp_name']);
     $hash = md5($content);
     $size = getimagesize($v['tmp_name']);
     $criteria = new Criteria();
     $criteria->add(ImagesPeer::CONTENT_HASH, $hash);
     $obj = ImagesPeer::doSelectOne($criteria);
     try {
         if (empty($obj)) {
             $obj = new Images();
             $obj->setNameDownloadedFile($v['name'])->setTypeImg($v['type'])->setHeight($size[2])->setWidth($size[1])->setContentHash($hash . '.jpg')->setContent(base64_encode($content))->setCreatedAt(date("Y-m-d H:i"))->setUpdatedAt(date("Y-m-d H:i"))->save();
         }
     } catch (Exception $e) {
         echo "stdfdfdfdfrt";
         die;
     }
     $criteria = new Criteria();
     $criteria->add(ImagesPeer::CONTENT_HASH, $obj->getContentHash());
     $obj = ImagesPeer::doSelectOne($criteria);
     // var_dump($obj->getId());die;
     return $obj->getId();
 }