We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The images are only deleted when we edit the campground. Deleting campground deletes the link to it, not the image.
The text was updated successfully, but these errors were encountered:
module.exports.deleteCampground = async (req, res) => { const { id } = req.params; const campground = await Campground.findById(id); const images = campground.images; const filenames = images.map((image) => image.filename); console.log(filenames); // prints an array of all the image filenames for (let filename of filenames) { cloudinary.uploader.destroy(filename); } await Campground.findByIdAndDelete(id); req.flash('success', 'Successfully deleted Campground.'); res.redirect('/campgrounds'); };
This code should work for deleting images from cloudinary.
Sorry, something went wrong.
module.exports.deleteCampground = async (req, res) => { const { id } = req.params; const campground = await Campground.findById(id); for (const img of campground.images) { cloudinary.uploader.destroy(img.filename); } await Campground.findByIdAndDelete(id); req.flash("success", "Successfully Deleted a Campgound.!"); res.redirect("/campgrounds"); };
No branches or pull requests
The images are only deleted when we edit the campground. Deleting campground deletes the link to it, not the image.
The text was updated successfully, but these errors were encountered: