Search for repo first before image id

Fixes #2791