@@ -4,6 +4,10 @@ Store Media in an external Storage
4
4
Sulu is able to upload newly created media files directly to an external storage provider (such as AWS S3 or
5
5
Google Cloud Storage).
6
6
7
+ .. warning ::
8
+
9
+ Please check the note :ref: `what-about-image-formats ` at the end of this document.
10
+
7
11
AWS-S3
8
12
------
9
13
@@ -93,3 +97,34 @@ Configure the storage with following yaml-snippet:
93
97
container_name : ' container-name'
94
98
path_prefix : ' optional path prefix'
95
99
100
+ .. _what-about-image-formats :
101
+
102
+ What About Image Formats?
103
+ -------------------------
104
+
105
+ .. note ::
106
+
107
+ Only the original files will be uploaded to the external storage. Image Formats / Thumbnails will still be generated
108
+ in the local directory. This is because image formats are generated in Sulu on demand, to explain in detail: when
109
+ an image format is requested for the first time, Sulu generates the image from the original file and stores it in the public
110
+ directory. The web server then acts as a kind of proxy. If the image is requested again, it checks the public
111
+ directory and directly returns the previously generated image instead of regenerating it. External storages like S3,
112
+ Google Cloud Storage or Azure Blob Storage do not support some kind of proxy or CDN functionality.
113
+
114
+ If you want to store the image formats in an external service you have to use a CDN like Fastly, Cloudflare or others
115
+ that support caching generated image formats for a long time. Some hosters allow to configure CDN directly on specific URLs
116
+ in Sulu all URLs under ``/uploads/media/* `` need to be routed through a proxy or CDN. If your chosen CDN
117
+ requires a custom Domain, you can use Symfony's CDN feature via:
118
+
119
+ ``{{ asset(media.thumbnail['40x40']) }} ``
120
+
121
+ and `configure a CDN Domain `_ in the Symfony configuration ``framework.assets `` configuration. If you have tested your proxy or CDN and it correctly
122
+ caches the generated images for a long time, you can disable saving the thumbnails to the local filesystem by setting
123
+ ``sulu_media.format_cache.save_image `` to ``false `` in ``config/packages/sulu_media.yaml ``, it is recommend to use an ENV variable
124
+ to locally still use it.
125
+
126
+ Important: Never disable the format cache unless you have set up a CDN or proxy. Otherwise, your server will
127
+ regenerate the image format on every request, which can overwhelm your server, as image generation is resource-intensive.
128
+
129
+
130
+ .. _Configure a CDN Domain : https://symfony.com/doc/6.4/reference/configuration/framework.html#base-urls
0 commit comments