If you were syncing the Contacts and photos to iCloud, have you gone to iCloud.com using a computer browser to see if they are there? If they are, have you signed into Settings/Your Name/iCloud using the same Apple ID you were using before, and turned syncing on? Allow time for the sync to complete. The photos sync is very, very slow.
If you weren't syncing them to iCloud, do you have a backup you can restore from? Restoring from a backup erases all data currently on your device. Any data newer than when the backup was made will be erased. A restore is an all or nothing restore. You can't access a backup and only restore certain files.
Backup - Restore your device from an iCloud or iTunes backup