File: image_loader.rst

package info (click to toggle)
thumbor 7.7.7-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 40,556 kB
  • sloc: xml: 295,435; python: 18,673; ansic: 1,479; makefile: 360; sh: 27
file content (83 lines) | stat: -rw-r--r-- 2,812 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
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'**.

Compatibility Loader
~~~~~~~~~~~~~~~~~~~~

The compatibility loader allows you to use legacy loaders (that do not support AsyncIO)
in order to make it easier to transition to thumbor's Python 3 version.

To use it you should set the **LOADER** configuration to
**'thumbor.compatibility.loader'**.

You also need to specify what's the legacy loader that the compatibility loader will use.
Just set the **COMPATIBILITY_LEGACY_LOADER** configuration to the full name of the legacy
loader you want to use. i.e.: COMPATIBILITY_LEGACY_LOADER = 'tc_aws.loaders.s3_loader'