Image loader

Pre-packaged loaders

thumbor comes pre-packaged with http and filesystem loaders.

Http loader

The http loader gets the original image portion of the URI and performs an HTTP GET to it. It then returns the image’s string representation.

The http loader uses the ALLOWED_SOURCES configuration to determine whether or not an image is from a trusted source and can thus be loaded.

You can specify the maximum size of the source image to be loaded. The http loader first gets the image size (without loading its contents), checks against your specified size and returns 404 if the source image size is larger than the max size. The max size option is MAX_SOURCE_SIZE and the default is no maximum size.

To use it you should set the LOADER configuration to ‘thumbor.loaders.http_loader’.

Https loader

The https loader works the same way as the http loader, except that it defaults to https instead of http.

To use it you should set the LOADER configuration to ‘thumbor.loaders.https_loader’.

Strict https loader

The strict https loader works the same way as the http loader, except that it only allows to load images over https.

To use it you should set the LOADER configuration to ‘thumbor.loaders.strict_https_loader’.

File loader

The file loader gets the original image portion of the URI and retrieves the file from the file system from a known path specified by the FILE_LOADER_ROOT_PATH configuration.

It joins the specified path with the configured root path and reads the image file if it exists.

To use it you should set the LOADER configuration to ‘thumbor.loaders.file_loader’.

File loader with http loader fallback

In some environments you need both kinds of file loading. For this use case you can use as loader with built-in fallback.

This loader will try to load images from local file storage. In case of an error the loader retry to load image with http_loader. If both attempts failed you’ll get an error.

To use it you should set the LOADER configuration to ‘thumbor.loaders.file_loader_http_fallback’.