Create own WordPress shortcode gallery

Are you going to put newlines in there between each image? or just spaces?
I’ll put in both for this example, checking if there’s a newline.

You would want something like this in your functions.php:

add_shortcode('my_gallery', 'gallery_function');
function gallery_function($atts, $code=""){
   $files=preg_split( '/\s+/', $code ); // Added in from Jan's comment.

   foreach($files as $img){
          continue; // ensures that no empty items from the split have entered in, since that is possible with the preg_split
      //handle each filename in here.

It’s not perfect.. if you use both spaces and newlines in your shortcode, it’ll mess things up – though that could be dealt with in more detail inside the function.

Hope this helps.