public function actionDeleteImage($id)
{
if (Yii::app()->request->isPostRequest) {
ImageToGallery::model()->findByPk((int) $id)->delete();
if (!isset($_GET['ajax'])) {
$this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : array('admin'));
}
} else {
throw new CHttpException(400, 'Invalid request. Please do not repeat this request again.');
}
}