소스 검색

Merge pull request #3925 from ci2014/patch-9

Update file.py
version-14
Rushabh Mehta 8 년 전
committed by GitHub
부모
커밋
ccdf8e846d
1개의 변경된 파일7개의 추가작업 그리고 3개의 파일을 삭제
  1. +7
    -3
      frappe/core/doctype/file/file.py

+ 7
- 3
frappe/core/doctype/file/file.py 파일 보기

@@ -170,7 +170,7 @@ class File(NestedSet):
super(File, self).on_trash()
self.delete_file()

def make_thumbnail(self):
def make_thumbnail(self, set_as_thumbnail=True, width=300, height=300, suffix="small"):
if self.file_url:
if self.file_url.startswith("/files"):
try:
@@ -184,15 +184,19 @@ class File(NestedSet):
except (requests.exceptions.HTTPError, requests.exceptions.SSLError, IOError):
return

size = 300, 300
size = width, height
image.thumbnail(size)

thumbnail_url = filename + "_small." + extn
thumbnail_url = filename + "_" + suffix + "." + extn

path = os.path.abspath(frappe.get_site_path("public", thumbnail_url.lstrip("/")))

try:
image.save(path)

if set_as_thumbnail:
self.db_set("thumbnail_url", thumbnail_url)

self.db_set("thumbnail_url", thumbnail_url)
except IOError:
frappe.msgprint(_("Unable to write file format for {0}").format(path))


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