# defining the size
x, y = [int(x) for x in size.split('x')]
# defining the filename and the miniature filename
- filehead, filetail = os.path.split(image.path)
+ try:
+ filehead, filetail = os.path.split(image.path)
+ except ValueError:
+ # return transparent pixel if the image doesn't actually exist
+ return 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABAQMAAAAl21bKAAAAA1BMVEUAAACnej3aAAAAAXRSTlMAQObYZgAAAApJREFUCNdjYAAAAAIAAeIhvDMAAAAASUVORK5CYII='
basename, format = os.path.splitext(filetail)
if format.lower() not in ('.jpg', '.jpeg'):
format = '.png'