예제 #1
0
    def on_save(self, uploaded_file):
        content = utils.file_from_content(uploaded_file.original_content)

        thumbnail = Image.open(content)
        thumbnail.thumbnail(self.thumbnail_size, Image.BILINEAR)
        thumbnail = thumbnail.convert('RGBA')
        thumbnail.format = self.thumbnail_format

        output = BytesIO()
        thumbnail.save(output, self.thumbnail_format)
        output.seek(0)

        thumb_file_name = 'thumb.%s' % self.thumbnail_format.lower()
        thumb_path, thumb_id = uploaded_file.store_content(output, thumb_file_name)
        uploaded_file['thumb_id'] = thumb_id
        uploaded_file['thumb_path'] = thumb_path
        uploaded_file['thumb_url'] = DepotManager.get_middleware().url_for(thumb_path)
예제 #2
0
    def on_save(self, uploaded_file):
        content = utils.file_from_content(uploaded_file.original_content)

        thumbnail = Image.open(content)
        thumbnail.thumbnail(self.thumbnail_size, Image.BILINEAR)
        thumbnail = thumbnail.convert('RGBA')
        thumbnail.format = self.thumbnail_format

        output = BytesIO()
        thumbnail.save(output, self.thumbnail_format)
        output.seek(0)

        thumb_name = 'thumb_%sx%s' % self.thumbnail_size
        thumb_file_name = '%s.%s' % (thumb_name, self.thumbnail_format.lower())
        thumb_path, thumb_id = uploaded_file.store_content(output, thumb_file_name)
        uploaded_file[thumb_name + '_id'] = thumb_id
        uploaded_file[thumb_name + '_path'] = thumb_path
        uploaded_file[thumb_name + '_url'] = DepotManager.get_middleware().url_for(thumb_path)
예제 #3
0
파일: fields.py 프로젝트: infobyte/faraday
 def thumb_url(self):
     public_url = self['_thumb_public_url']
     if public_url:
         return public_url
     return DepotManager.get_middleware().url_for(self['thumb_path'])
예제 #4
0
 def thumb_url(self):
     public_url = self['_thumb_public_url']
     if public_url:
         return public_url
     return DepotManager.get_middleware().url_for(self['thumb_path'])
예제 #5
0
 def test_detects_no_middleware(self):
     DepotManager.get_middleware()
예제 #6
0
 def test_detects_no_middleware(self):
     DepotManager.get_middleware()