nodes: 0, module; 1, function_definition; 2, function_name:image_field_data; 3, parameters; 4, block; 5, identifier:request; 6, default_parameter; 7, expression_statement; 8, try_statement; 9, expression_statement; 10, expression_statement; 11, for_statement; 12, if_statement; 13, return_statement; 14, identifier:include_empty_option; 15, False; 16, comment:"""Returns a list of tuples of all images.
  
      Generates a sorted list of images available. And returns a list of
      (id, name) tuples.
  
      :param request: django http request object
      :param include_empty_option: flag to include a empty tuple in the front of
          the list
  
      :return: list of (id, name) tuples
  
      """; 17, block; 18, except_clause; 19, call; 20, assignment; 21, identifier:image; 22, identifier:images; 23, block; 24, not_operator; 25, block; 26, identifier:images_list; 27, expression_statement; 28, identifier:Exception; 29, block; 30, attribute; 31, argument_list; 32, identifier:images_list; 33, list; 34, expression_statement; 35, expression_statement; 36, identifier:images; 37, return_statement; 38, assignment; 39, expression_statement; 40, identifier:images; 41, identifier:sort; 42, keyword_argument; 43, tuple; 44, assignment; 45, call; 46, list; 47, identifier:images; 48, call; 49, call; 50, identifier:key; 51, lambda; 52, string; 53, call; 54, identifier:image_label; 55, call; 56, attribute; 57, argument_list; 58, tuple; 59, identifier:get_available_images; 60, argument_list; 61, attribute; 62, argument_list; 63, lambda_parameters; 64, attribute; 65, identifier:_; 66, argument_list; 67, attribute; 68, argument_list; 69, identifier:images_list; 70, identifier:append; 71, tuple; 72, string:""; 73, call; 74, identifier:request; 75, attribute; 76, identifier:exceptions; 77, identifier:handle; 78, identifier:request; 79, call; 80, identifier:c; 81, identifier:c; 82, identifier:name; 83, string; 84, string:u"{} ({})"; 85, identifier:format; 86, attribute; 87, call; 88, attribute; 89, identifier:image_label; 90, identifier:_; 91, argument_list; 92, attribute; 93, identifier:project_id; 94, identifier:_; 95, argument_list; 96, string_content:Select Image; 97, identifier:image; 98, identifier:name; 99, identifier:filesizeformat; 100, argument_list; 101, identifier:image; 102, identifier:id; 103, string:"No images available"; 104, identifier:request; 105, identifier:user; 106, string; 107, attribute; 108, string_content:Unable to retrieve images; 109, identifier:image; 110, identifier:size
code: def image_field_data(request, include_empty_option=False):
      """Returns a list of tuples of all images.
  
      Generates a sorted list of images available. And returns a list of
      (id, name) tuples.
  
      :param request: django http request object
      :param include_empty_option: flag to include a empty tuple in the front of
          the list
  
      :return: list of (id, name) tuples
  
      """
      try:
          images = get_available_images(request, request.user.project_id)
      except Exception:
          exceptions.handle(request, _('Unable to retrieve images'))
      images.sort(key=lambda c: c.name)
      images_list = [('', _('Select Image'))]
      for image in images:
          image_label = u"{} ({})".format(image.name, filesizeformat(image.size))
          images_list.append((image.id, image_label))
  
      if not images:
          return [("", _("No images available")), ]
  
      return images_list