If you look at the code of the "Resize Images" extension, you will see that the Cloud Function that underlies the extension is triggered by a onFinalize
event, which means:
When a new object (or a new generation of an existing object) is
successfully created in the bucket. This includes copying or rewriting
an existing object.
So, without rewriting/regenerating the existing images the Extension will not be triggered.
However, you could easily write your own Cloud Function that does the same thing but is triggered, for example, by a call to a specific URL (HTTPS cloud Function) or by creating a new document in a temporary Firestore Collection (background triggered CF).
This Cloud Function would execute the following steps:
- Get all the files of your bucket, see the
getFiles()
method of the Google Cloud Storage Node.js Client API. This method returns a GetFilesResponse
object which is an Array of File
instances.
- By looping over the array, for each file, check if the file has a corresponding resized image in the bucket (depending on the way you configured the Extension, the resized images may be in a specific folder)
- If a file does not have a corresponding resized image, execute the same business logic of the Extension Cloud Function for this File.
Depending on the number of images to treat, you may need to increase the timeout value and/or the allocated memory of your Cloud Function, see https://firebase.google.com/docs/functions/manage-functions#set_timeout_and_memory_allocation