def view_picture(request): picture = request.ductus.resource mime_type = picture.blob.mime_type # figure out size to send thumbnail_str = '' if 'max_size' in request.GET: try: max_width, max_height = [ int(n) for n in request.GET['max_size'].split(',') ] except ValueError: return query_string_not_found(request) try: thumbnail_size = six.next( iter(s for s in __allowed_thumbnail_sizes if s <= (max_width, max_height))) except StopIteration: # refuse to make a thumbnail this small return query_string_not_found(request) thumbnail_str = '_'.join(str(s) for s in thumbnail_size) if picture.rotation: thumbnail_str += '_' + picture.rotation #TODO: we probably shouldn't convert png images to jpeg... return mediacache_redirect(request, picture.blob.href, 'image/jpeg', thumbnail_str, picture)
def view_picture(request): picture = request.ductus.resource mime_type = picture.blob.mime_type # figure out size to send thumbnail_str = '' if 'max_size' in request.GET: try: max_width, max_height = [int(n) for n in request.GET['max_size'].split(',')] except ValueError: return query_string_not_found(request) try: thumbnail_size = six.next(iter(s for s in __allowed_thumbnail_sizes if s <= (max_width, max_height))) except StopIteration: # refuse to make a thumbnail this small return query_string_not_found(request) thumbnail_str = '_'.join(str(s) for s in thumbnail_size) if picture.rotation: thumbnail_str += '_' + picture.rotation #TODO: we probably shouldn't convert png images to jpeg... return mediacache_redirect(request, picture.blob.href, 'image/jpeg', thumbnail_str, picture)
def view_audio(request): audio = request.ductus.resource return mediacache_redirect(request, audio.blob.href, audio.blob.mime_type, '', audio)