On Desktop/Browser #
Just click the “Mark as spoiler” option while sharing a picture and you are good to go.
On Mobile #
On mobile, it is a bit trickier. What you need to do is rename the photo name so for example if the image name is “example.jpg” you need to make it “SPOILER_example.jpg”. Just add the “SPOILER_” in front of whatever the file name is and share that photo, it will be automatically spoilered.
Add your images to your files app. Rename your picture to SPOILER_[imagename] (SPOILER has to be all capital letters). Then attach the file to discord through your Files app, not your gallery or other apps.
Go to your file manager. Rename the picture to SPOILER_[imagename]. Now it is renamed you can share it on discord.