For Add Link we want to invalidate the recommendation when the user accepts some links, or rejects some links, or some non-AddLink edit is made to the article. For Add Image we don't want the last case as most edits don't affect the "needs image" status of the article. (In theory we could try to detect whether an image has been added and selectively invalidate but it's probably not worth the hassle. It's easier to detect on the client side and show a no suggestion error, and we don't expect it to be that frequent.)
Also, for Add Link invalidation involves deleting from the index and the database; for Add Image there's only the search index. For Add Link we are also relying on the database to decide when to delete, for Add Image that won't work.
Update the code to handle the differences. Probably the easiest is to do invalidation in the submission handler (see T289024: Add Image: Backend handling of user acceptance/rejection of image recommendations), and leave HomepageHooks::onSearchDataForIndex() as it is (to only handle Add Link edits), so this can probably be done as part of T289024.