error fix in imageController

added isset and is_object to prevent if function trying to access non
objects/non existing.