Fix: Checking for array is redundat, PHP will throw fatal before we reach this.
Moved image functions into their own namespace.
Check if images are valid before importing
Don't use file_get_contents() for remote URLs, use WP functions instead.
Fixed some PHP notices and errors.