/** * Deletes an image variation based on the given title. * */ public function deleteVariation() { $ajax = EasyBlogHelper::getHelper('Ajax'); // This is the relative path to the items that needs to be deleted. $relativePath = JRequest::getVar('fromPath'); // This let's us know the type of folder we should lookup to $place = JRequest::getString('place'); // @task: Create the media object. $media = new EasyBlogMediaManager(); // The variation name. $variationName = JRequest::getVar('name'); // @task: Let's find the exact path first as there could be 3 possibilities here. // 1. Shared folder // 2. User folder $absolutePath = EasyBlogMediaManager::getAbsolutePath($relativePath, $place); // @task: Let's test if the source folder really exist. if (!$media->exists($absolutePath)) { return $ajax->fail(JText::_('COM_EASYBLOG_FILE_OR_FOLDER_DOES_NOT_EXIST')); } // @task: Try to rename the source to destination $state = $media->deleteVariation($absolutePath, $variationName); // @task: If failed, let's just return a failed status if ($state !== true) { return $ajax->fail($state); } // @task: Return the deleted path's relative path return $ajax->success(); }