Fixes #7997 - Fixing foreign key on tags relationship for images