There are two ways to keep your WhatsApp photos from taking up space on your phone: through Google Photos and with WhatsApp. Let's see them below

Through Google Photos

Download and install Google Photos (although on most devices it comes pre-installed) with the following button.

Once you have done that, open the application. As soon as you have done so, tap on the menu button (in the top left corner of the screen):

Google Photos main interfaceGoogle Photos main interface

Then tap on Settings:

Google Photos menuGoogle Photos menu

Now tap on Back up & sync:

Google Photos settingsGoogle Photos settings

Activate backup and synchronization of your photos (the control button must be blue):

Cloud storage enabledCloud storage enabled

Now that the backup is activated, tap on the Albums tab:

Navigation buttons in Google PhotosNavigation buttons in Google Photos

Now, tap on WhatsApp Images:

Album view in Google PhotosAlbum view in Google Photos

Next, look at the top of the screen, at the Back up & sync control:

Button to back up a folder on the cloudButton to back up a folder on the cloud

Tap the control button to activate it (remember it has to be blue):

Backup enabledBackup enabled

From now on, Google Photos will store all the photos in your WhatsApp image folder in the cloud. Also, every time someone sends you a new photo, it will be copied and synchronized with your cloud storage. You will receive a notification when the sync is complete, so you can then delete all WhatsApp photos from your device.

Through WhatsApp

The best way to prevent photos from taking up storage space on WhatsApp is to prevent them from being downloaded. By default the messaging app downloads everything sent to us automatically, but we can change that behavior. To do this, open WhatsApp and tap on the menu button:

WhatsApp’s main screenWhatsApp’s main screen

Now, tap on Settings:

WhatsApp’s dropdown menuWhatsApp’s dropdown menu

Next, tap on Data and storage usage:

WhatsApp’s settingsWhatsApp’s settings

Now, let's look at the Media auto-download section:

Default storage optionsDefault storage options

We will have to enter the three options (When using mobile data, When connected on Wi-Fi, and When roaming), and uncheck all the categories that will appear when tapping on each of them:

Changing the storage optionsChanging the storage options

When you are done, each option should show the No Media message:

WhatsApp storage disabledWhatsApp storage disabled

And that is it, any content sent to you by WhatsApp (not just photos) will not be automatically downloaded to your device, and therefore will not take up space.