parameters: (self)
return_statement: return self.html_template.format(
              link=link, src=data_uri, width=im.size[0], height=im.size[1])
docstring: Returns :attr:`self.file_obj` as an <img> tag with the src set to a
          data::URI.
docstring_summary: Returns :attr:`self.file_obj` as an <img> tag with the src set to a
          data::URI.
docstring_tokens: Returns : attr : self . file_obj as an <img > tag with the src set to a data :: URI .
function: def html(self):
          """
          Returns :attr:`self.file_obj` as an <img> tag with the src set to a
          data::URI.
          """
          try:
              from PIL import Image
          except ImportError:
              return # Warnings will have already been printed by this point
          if not self.file_obj:
              return u""
          self.file_obj.seek(0)
          try:
              im = Image.open(self.file_obj)
          except IOError:
              # i.e. PIL couldn't identify the file
              return u"<i>Error displaying image</i>"
          self.file_obj.seek(0)
          # Need to encode base64 to create a data URI
          encoded = base64.b64encode(self.file_obj.read())
          data_uri = "data:image/{type};base64,{encoded}".format(
              type=im.format.lower(), encoded=encoded.decode('utf-8'))
          link = "%s/%s" % (self.linkpath, os.path.split(self.path)[1])
          if self.original_file:
              link = "%s/%s" % (
                  self.linkpath, os.path.split(self.original_file.name)[1])
          if self.thumbnail:
              return self.html_icon_template.format(
                  link=link,
                  src=data_uri,
                  width=im.size[0],
                  height=im.size[1])
          return self.html_template.format(
              link=link, src=data_uri, width=im.size[0], height=im.size[1])
function_tokens: def html ( self ) : try : from PIL import Image except ImportError : return # Warnings will have already been printed by this point if not self . file_obj : return u"" self . file_obj . seek ( 0 ) try : im = Image . open ( self . file_obj ) except IOError : # i.e. PIL couldn't identify the file return u"<i>Error displaying image</i>" self . file_obj . seek ( 0 ) # Need to encode base64 to create a data URI encoded = base64 . b64encode ( self . file_obj . read ( ) ) data_uri = "data:image/{type};base64,{encoded}" . format ( type = im . format . lower ( ) , encoded = encoded . decode ( 'utf-8' ) ) link = "%s/%s" % ( self . linkpath , os . path . split ( self . path ) [ 1 ] ) if self . original_file : link = "%s/%s" % ( self . linkpath , os . path . split ( self . original_file . name ) [ 1 ] ) if self . thumbnail : return self . html_icon_template . format ( link = link , src = data_uri , width = im . size [ 0 ] , height = im . size [ 1 ] ) return self . html_template . format ( link = link , src = data_uri , width = im . size [ 0 ] , height = im . size [ 1 ] )