소스 검색

Add is_image util (#4605)

version-14
Faris Ansari 7 년 전
committed by Nabin Hait
부모
커밋
49b63d7680
2개의 변경된 파일8개의 추가작업 그리고 1개의 파일을 삭제
  1. +1
    -1
      frappe/templates/print_formats/standard_macros.html
  2. +7
    -0
      frappe/utils/data.py

+ 1
- 1
frappe/templates/print_formats/standard_macros.html 파일 보기

@@ -112,7 +112,7 @@ data-fieldname="{{ df.fieldname }}" data-fieldtype="{{ df.fieldtype }}"
<img src="{{ doc[df.fieldname] }}" class="signature-img img-responsive"
{%- if df.print_width %} style="width: {{ get_width(df) }};"{% endif %}>
{% elif df.fieldtype in ("Attach", "Attach Image") and doc[df.fieldname]
and (guess_mimetype(doc[df.fieldname])[0] or "").startswith("image/") %}
and frappe.utils.is_image(doc[df.fieldname]) %}
<img src="{{ doc[df.fieldname] }}" class="img-responsive"
{%- if df.print_width %} style="width: {{ get_width(df) }};"{% endif %}>
{% elif df.fieldtype=="HTML" %}


+ 7
- 0
frappe/utils/data.py 파일 보기

@@ -516,6 +516,13 @@ def is_html(text):
break
return out

def is_image(filepath):
from mimetypes import guess_type

# filepath can be https://example.com/bed.jpg?v=129
filepath = filepath.split('?')[0]
return (guess_type(filepath)[0] or "").startswith("image/")


# from Jinja2 code
_striptags_re = re.compile(r'(<!--.*?-->|<[^>]*>)')


불러오는 중...
취소
저장