And the bash (-compatible) equivalent:
#!/bin/sh

num=0

arrname="images"
[ -n "$1" ] && arrname="$1"

imgpath=""
[ -n "$2" ] && imgpath="$2"