function delete_image_cdn($img) { if (strpos($img, "cloudinary")) { $x = explode("/", $img); $y = explode(".", $x[count($x) - 1]); if ($y[0] != "default") { \Cloudinary\Uploader::destroy($y[0], array("invalidate" => true)); } } }
function wppa_delete_from_cloudinary($id) { $prefix = is_multisite() && !WPPA_MULTISITE_GLOBAL ? $blog_id . '-' : ''; $pub_id = $prefix . $id; $args = array("invalidate" => true); \Cloudinary\Uploader::destroy($pub_id, $args); }
/** * Delete file using public ID * * @param string $publicId * @param array $options * @throws CakeException */ public function delete($publicId = null, $options = array()) { if (!empty($publicId)) { $status = \Cloudinary\Uploader::destroy($publicId, $options); if ($status['result'] == 'ok') { return true; } else { throw new CakeException(__d('cake_dev', $publicId . ' is not found or already deleted.')); } } else { throw new CakeException(__d('cake_dev', 'Public ID is missing')); } }
public function deleteImage(Image $image) { Uploader::destroy($image->getId()); }
return redirect(url('/admin'))->withInput()->withErrors($validator); } $user = User::find($data['user_id'])->delete(); return redirect(url('/admin')); }); Route::delete('/admin/deleteproperty', function (Request $request) { $data = $request->all(); $validator = Validator::make($request->all(), ['property_id' => 'required|numeric|integer|min:0']); if ($validator->fails()) { return redirect(url('/admin'))->withInput()->withErrors($validator); } $user = Property::find($data['property_id'])->delete(); return redirect(url('/admin')); }); Route::delete('/property/photo/{picture}', function (Picture $picture) { \Cloudinary\Uploader::destroy($picture->cloudinary_public_id); $property_id = PropertyPictureBridge::where('picture_id', $picture->id)->get()[0]->property_id; $picture->delete(); return redirect(url('/property/edit/photos/' . $property_id)); }); Route::get('/property/edit/{property_id}', function ($property_id) { $cities = City::orderBy('name', 'asc')->get(); $property = Property::find($property_id); $property->district_name = District::find($property->district_id)->name; $property->city_name = City::find($property->city_id)->name; $amenities = PropertyFeatures::where('property_id', $property->id)->get()[0]; return view('edit_property', ['property' => $property, 'cities' => $cities, 'amenities' => $amenities]); }); Route::get('/property/edit/photos/{property_id}', function ($property_id) { $property = Property::find($property_id); $images = get_all_images_from_property_id_without_placeholder($property_id);
/** * Delete media */ public function delete() { /* if (isset($this->id)) { if (file_exists($this->get_path(self::STYLE_ROOT))) unlink($this->get_path(self::STYLE_ROOT)); }*/ if ($this->public_id) { \Cloudinary\Uploader::destroy($this->public_id); } return parent::delete(); }
function delete($id = '') { if ($this->session->userdata('logged_in')) { $id = isset($_POST['id']) ? $_POST['id'] : 0; $r = $this->user_model->get_by_id($id); if (strpos($r->image, "cloudinary")) { $x = explode("/", $r->image); $y = explode(".", $x[count($x) - 1]); if ($y[0] != "default") { \Cloudinary\Uploader::destroy($y[0], array("invalidate" => true)); } } $this->user_model->delete_user($id); $t = array("success" => true, "username" => $r->user_name, "f" => "delete"); $this->session->set_userdata("t", $t); //redirect('admin/user'); } else { redirect('admin/login', 'refresh'); } }
/** * Delete a file. * * @param string $path * * @return bool */ public function delete($path) { $result = Uploader::destroy($path, ['invalidate' => true]); return is_array($result) ? $result['result'] == 'ok' : false; }
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($project) { Cloudinary::config(array("cloud_name" => "seniva", "api_key" => "572854663344648", "api_secret" => "8YqjessAxqDJeOtU4SUYUPedRV8")); $project = Project::find($project); foreach ($project->images as $image) { Cloudinary\Uploader::destroy($image->public_id); $image->delete(); } $project->delete(); return redirect()->back(); }
public function delete() { $options['return_error'] = false; $ret = \Cloudinary\Uploader::destroy($this->_identifier); unset($this->_identifier); }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function delete($id) { $media = Media::find($id); if ($media->user_id == Auth::user()->id || Auth::user()->admin == 1) { $media_flags = MediaFlag::where('media_id', '=', $id)->get(); foreach ($media_flags as $media_flag) { $media_flag->delete(); } $media_likes = MediaLike::where('media_id', '=', $id)->get(); foreach ($media_likes as $media_like) { $media_like->delete(); } $comments = Comment::where('media_id', '=', $id)->get(); foreach ($comments as $comment) { $comment_votes = CommentVote::where('comment_id', '=', $comment->id)->get(); foreach ($comment_votes as $comment_vote) { $comment_vote->delete(); } $comment_flags = CommentFlag::where('comment_id', '=', $comment->id)->get(); foreach ($comment_flags as $comment_flag) { $comment_flag->delete(); } $comment->delete(); } $arrayPicUrl = explode("/", $media->pic_url); // if the media type is a gif we need to remove the animation file too. if (strpos($media->pic_url, '.gif') > 0) { \Cloudinary\Uploader::destroy(Constant::FOLDER_CLOUDINARY . '/' . $arrayPicUrl[0] . '/' . pathinfo(str_replace(".gif", "-animation.gif", $media->pic_url), PATHINFO_FILENAME)); } // remove the image \Cloudinary\Uploader::destroy(Constant::FOLDER_CLOUDINARY . '/' . $arrayPicUrl[0] . '/' . pathinfo($media->pic_url, PATHINFO_FILENAME)); $media->delete(); } return Redirect::to('admin?section=media')->with(array('note' => Lang::get('lang.delete_success'), 'note_type' => 'success')); }
public function RemoveImageFromCloudinary($public_id) { $this->init(); require_once "Uploader.php"; if (is_null($this->arrCloudinary)) { return false; } Yii::log('Deleting /' . $public_id . " " . print_r($this->arrCloudinary, true), 'info', 'application.' . __CLASS__ . "." . __FUNCTION__); \Cloudinary::config(array("cloud_name" => $this->arrCloudinary['cloud_name'], "api_key" => $this->arrCloudinary['api_key'], "api_secret" => $this->arrCloudinary['api_secret'])); $arrReturn = \Cloudinary\Uploader::destroy($public_id, array("invalidate" => TRUE)); Yii::log('Returned from Cloudinary ' . print_r($arrReturn, true), 'info', 'application.' . __CLASS__ . "." . __FUNCTION__); return $arrReturn; }
public function upload(UploadedFile $file, $public_id) { \Cloudinary\Uploader::destroy($public_id); $information = \Cloudinary\Uploader::upload($file->getRealPath(), ['public_id' => $public_id]); return json_encode($information); }