public function deleteImageByName($filename)
    {
        $destinationPath = $this->getDestinationPath();

        $images = $this->getImages();

        foreach ($images as $key => $image) {
            if ($image->file == $filename) {
                foreach ($image->set as $imageSetFilename) {
                    $destination = $destinationPath . '/' . $imageSetFilename;
                    if (file_exists($destination)) {
                        unlink($destination);
                    }
                }
                unset($images[$key]);
            }
        }
        $images = array_values($images);
        $this->repository->images = $images;
        $this->save();
    }
public function deleteImageByName($filename)
    {
        $destinationPath = $this->getDestinationPath();

        $images = $this->getImages();

        foreach ($images as $key => $image) {
            if ($image->file == $filename) {
                foreach ($image->set as $imageSetFilename) {
                    $destination = $destinationPath . '/' . $imageSetFilename;
                    if (file_exists($destination)) {
                        unlink($destination);
                    }
                }
                unset($images[$key]);
            }
        }
        $images = array_values($images);
        $this->repository->images = $images;
        $this->save();
    }
public function deleteImageByName ( $ filename ) { $ destinationPath = $ this -> getDestinationPath ( ) ; $ images = $ this -> getImages ( ) ; foreach ( $ images as $ key => $ image ) { if ( $ image -> file == $ filename ) { foreach ( $ image -> set as $ imageSetFilename ) { $ destination = $ destinationPath . '/' . $ imageSetFilename ; if ( file_exists ( $ destination ) ) { unlink ( $ destination ) ; } } unset ( $ images [ $ key ] ) ; } } $ images = array_values ( $ images ) ; $ this -> repository -> images = $ images ; $ this -> save ( ) ; }
Delete image by name
@param $filename
Delete image by name