added optional handling of image array to attach to post