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)
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)
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'])
def test_detects_no_middleware(self): DepotManager.get_middleware()