Twenty Eleven: improve how gallery image IDs are retrieved for use in the Gallery post format template. Props to obenland for original patch, fixes #22907.

git-svn-id: http://core.svn.wordpress.org/trunk@23824 1a063a9b-81f0-0310-95a4-ce76da25c4cd