You can fix and stop photos from opening with a few changes right in your Mac OS X by the following 2 steps:
Step 1: Once the Mac opens the photos when you connect your device to it, just go to the "Import" tab on the top.
Connect your iPhone or iPad using the cable to your computer. When your computer automatically launches the Photos for the connected device, go to the tab called “Import” on the top, then uncheck on "Open Photos for this Device" option.
Step 2: This step is just a backup solution of step 1 does not work. Just enter the following command line into Terminal (Found in Applications Folder)
defaults -currentHost write com.apple.ImageCapturedisableHotPlug -bool true