當前位置: 首頁>>代碼示例>>Python>>正文


Python HTML.img方法代碼示例

本文整理匯總了Python中webhelpers2.html.HTML.img方法的典型用法代碼示例。如果您正苦於以下問題:Python HTML.img方法的具體用法?Python HTML.img怎麽用?Python HTML.img使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在webhelpers2.html.HTML的用法示例。


在下文中一共展示了HTML.img方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_html

# 需要導入模塊: from webhelpers2.html import HTML [as 別名]
# 或者: from webhelpers2.html.HTML import img [as 別名]
def test_html():
    a = HTML.a(href='http://mostlysafe\" <tag', c="Bad <script> tag")
    eq_(a, u'<a href="http://mostlysafe&#34; &lt;tag">Bad &lt;script&gt; tag</a>')
    
    img = HTML.img(src='http://some/image.jpg')
    eq_(img, u'<img src="http://some/image.jpg" />')
    
    br = HTML.br()
    eq_(u'<br />', br)
開發者ID:aodag,項目名稱:WebHelpers2,代碼行數:11,代碼來源:test_html.py

示例2: test_html

# 需要導入模塊: from webhelpers2.html import HTML [as 別名]
# 或者: from webhelpers2.html.HTML import img [as 別名]
 def test_html(self):
     a = HTML.a(href='http://mostlysafe\" <tag', c="Bad <script> tag")
     assert a == '<a href="http://mostlysafe&#34; &lt;tag">Bad &lt;script&gt; tag</a>'
     
     img = HTML.img(src="http://some/image.jpg")
     assert img == '<img src="http://some/image.jpg" />'
     
     br = HTML.br()
     assert "<br />" == br
開發者ID:jManji,項目名稱:Trivia,代碼行數:11,代碼來源:test_html.py

示例3: image

# 需要導入模塊: from webhelpers2.html import HTML [as 別名]
# 或者: from webhelpers2.html.HTML import img [as 別名]
def image(url, alt, width=None, height=None, path=None, use_pil=False, 
    **attrs):
    """Return an image tag for the specified ``source``.

    ``url``
        The URL of the image.  (This must be the exact URL desired.  A
        previous version of this helper added magic prefixes; this is
        no longer the case.)
    
    ``alt``
        The img's alt tag. Non-graphical browsers and screen readers will
        output this instead of the image.  If the image is pure decoration
        and uninteresting to non-graphical users, pass "".  To omit the
        alt tag completely, pass None.

    ``width``
        The width of the image, default is not included.

    ``height``
        The height of the image, default is not included.

    ``path``
        Calculate the width and height based on the image file at ``path`` if
        possible. May not be specified if ``width`` or ``height`` is 
        specified. The results are also written to the debug log for
        troubleshooting.

    ``use_pil``
        If true, calcuate the image dimensions using the Python Imaging 
        Library, which must be installed. Otherwise use a pure Python
        algorithm which understands fewer image formats and may be less
        accurate. This flag controls whether
        ``webhelpers2.media.get_dimensions_pil`` or
        ``webhelpers2.media.get_dimensions`` is called. It has no effect if
        ``path`` is not specified.
        
    Examples::

        >>> image('/images/rss.png', 'rss syndication')
        literal(u'<img alt="rss syndication" src="/images/rss.png" />')

        >>> image('/images/xml.png', "")
        literal(u'<img alt="" src="/images/xml.png" />')

        >>> image("/images/icon.png", height=16, width=10, alt="Edit Entry")
        literal(u'<img alt="Edit Entry" height="16" src="/images/icon.png" width="10" />')

        >>> image("/icons/icon.gif", alt="Icon", width=16, height=16)
        literal(u'<img alt="Icon" height="16" src="/icons/icon.gif" width="16" />')

        >>> image("/icons/icon.gif", None, width=16)
        literal(u'<img alt="" src="/icons/icon.gif" width="16" />')
    """
    if not alt:
        alt = ""
    if width is not None or height is not None:
        attrs['width'] = width
        attrs['height'] = height
        if path:
            raise TypeError(
                "can't specify path if width and height are specified")
    elif path:
        if use_pil:
            result = media.get_dimensions_pil(path)
            msg = "using PIL"
        else:
            result = media.get_dimensions(path)
            msg = "not using PIL"
        abspath = os.path.abspath(path)
        log.debug("image size is %s for '%s' (%s)", result, abspath, msg)
        attrs['width'] = result[0]
        attrs['height'] = result[1]
    return HTML.img(src=url, alt=alt, **attrs)
開發者ID:aodag,項目名稱:WebHelpers2,代碼行數:75,代碼來源:tags.py

示例4: paging_img_last_dead

# 需要導入模塊: from webhelpers2.html import HTML [as 別名]
# 或者: from webhelpers2.html.HTML import img [as 別名]
 def paging_img_last_dead(self):
     img_url = self.manager.static_url('bd_lastpage.png')
     return _HTML.img(src=img_url, width=16, height=13, alt='>>')
開發者ID:level12,項目名稱:webgrid,代碼行數:5,代碼來源:renderers.py

示例5: paging_img_next

# 需要導入模塊: from webhelpers2.html import HTML [as 別名]
# 或者: from webhelpers2.html.HTML import img [as 別名]
 def paging_img_next(self):
     img_url = self.manager.static_url('b_nextpage.png')
     return _HTML.img(src=img_url, width=8, height=13, alt='>')
開發者ID:level12,項目名稱:webgrid,代碼行數:5,代碼來源:renderers.py

示例6: paging_img_prev_dead

# 需要導入模塊: from webhelpers2.html import HTML [as 別名]
# 或者: from webhelpers2.html.HTML import img [as 別名]
 def paging_img_prev_dead(self):
     img_url = self.manager.static_url('bd_prevpage.png')
     return _HTML.img(src=img_url, width=8, height=13, alt='<')
開發者ID:level12,項目名稱:webgrid,代碼行數:5,代碼來源:renderers.py

示例7: paging_img_first

# 需要導入模塊: from webhelpers2.html import HTML [as 別名]
# 或者: from webhelpers2.html.HTML import img [as 別名]
 def paging_img_first(self):
     img_url = self.manager.static_url('b_firstpage.png')
     return _HTML.img(src=img_url, width=16, height=13, alt='<<')
開發者ID:level12,項目名稱:webgrid,代碼行數:5,代碼來源:renderers.py


注:本文中的webhelpers2.html.HTML.img方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。