docs: def attach_image(field, nested_fields, page, record_keeper=None):
      '''
      Returns a function that attaches an image to page if it exists
  
      Currenlty assumes that images have already been imported and info
      has been stored in record_keeper
      '''
      if (field in nested_fields) and nested_fields[field]:
          foreign_image_id = nested_fields[field]["id"]
          # Handle the following
          # record keeper may not exist
          # record keeper may not have image ref
          if record_keeper:
              try:
                  local_image_id = record_keeper.get_local_image(
                      foreign_image_id)
                  local_image = Image.objects.get(id=local_image_id)
                  setattr(page, field, local_image)
              except ObjectDoesNotExist:
                  raise ObjectDoesNotExist(
                      ("executing attach_image: local image referenced"
                       "in record_keeper does not actually exist."),
                      None)
              except Exception:
                  raise
          else:
              raise Exception(
                  ("Attempted to attach image without record_keeper. "
                   "This functionality is not yet implemented"))