Make multi media picker directive handle multiple images?

I was following the post by Tim here: http://www.nibble.be/?p=440

I got the code working to handle one image in the media picker, but I want the user to be able to pick multiple images. On save, I then basically want to save the image id’s in an external table. I set the multi flag to true, but the directive is setup for single image only. How can I modify it to handle multiple images? Here is the directive:

angular.module("umbraco.directives")
.directive('umbMediaPicker', function (dialogService, entityResource) {
    return {
        restrict: 'E',
        replace: true,
        templateUrl: '/App_Plugins/Products/umb-media-picker.html',
        require: "ngModel",
        link: function (scope, element, attr, ctrl) {

            ctrl.$render = function () {
                var val = parseInt(ctrl.$viewValue);
                if (!isNaN(val) && angular.isNumber(val) && val > 0) {
                   
                    entityResource.getById(val, "Media").then(function (item) {
                        scope.node = item;
                    });
                }
            };

            scope.openMediaPicker = function () {
                dialogService.mediaPicker({
                    multiPicker: true,
                    callback: populatePicture
                });
            }

            scope.removePicture = function () {
                scope.node = undefined;
                updateModel(0);
            }

            function populatePicture(item) {

                scope.node = item;
                updateModel(item.id);
            }

            function updateModel(id) {
                ctrl.$setViewValue(id);

            }
        }
    };
});

This is a companion discussion topic for the original entry at https://our.umbraco.com/forum/72004-make-multi-media-picker-directive-handle-multiple-images