I noticed one problem with your solution :-/
My client wants to have a certain sorting the images will appear in the portfolio. with your change, I have to rename the title of the post to have this sorted in the right way.
this will end up in posts named like 01_xxx, 02_xxx, etc…
Isn’t there another way to have a custom sorting? like an index given for each gallery entry?