protected function deleteProjectImages(Crowdfunding\Project $project, $folderImages) { $images = array("image" => $project->getImage(), "image_square" => $project->getSquareImage(), "image_small" => $project->getSmallImage()); // Remove foreach ($images as $image) { $imageFile = JPath::clean(JPATH_ROOT . DIRECTORY_SEPARATOR . $folderImages . DIRECTORY_SEPARATOR . $image); if (JFile::exists($imageFile)) { JFile::delete($imageFile); } } }