def make_thumbnails(self): count = 0 size = len(self.gen_thumbnails) for path, width, height in sorted(self.gen_thumbnails): count += 1 yield "Generating thumbnail %d of %d" % (count, size) media_path = media_mapper._map_path(path) if media_path is None: continue if not os.path.exists(media_path): # FIXME - warn better. continue thumbdata, thumbmime = thumbcache.get_data(media_path, width, height) assert width is not None zippath = self.lookup_path('thumbnail', (), dict(path=path, width=width, height=height)) self.addfile(zippath, thumbdata)
def thumbnail(self, path, width=64, height=64): if not mapper.exists(path): redirect(url("/static/icons/thumbs/missing.png")) width = int(width) height = int(height) # Note - the path supplied is supplied as a query parameter, not as # part of the path info in the URL, because otherwise cherrypy strips # out any double slashes, making it impossible to tell if the path # starts with a drivename (on windows) or with an absolute path which # should have a / inserted before it (on unix). try: data, ctype = thumbcache.get_data(mapper._map_path(path), width, height) cherrypy.response.headers["Content-Type"] = ctype return data except IOError: redirect(url("/static/icons/thumbs/broken.png"))