ideas
ideas copied to clipboard
Statamic image handling/manipulation
Hello gentleman, atm we dig into image handling/manipulation a little deeper and i want to ask/discuss some topics:
- If we use asset cache and presets, we will run into problems:
- Waste of disc space: I upload a product image and all presets will be generated, also the presets i will never use with this image (for example the logo_desktop preset)
- Images are generated synchronously, with many of them you will run into php runtime limits
- If we use asset cache without presets:
- Glide Tag: Images are generated synchronously on url generation (!), not if the image url is requested (BUG?) - which might cause long loading times if image is not cached and runtime limit problems (many images on a page with empty cache)
- Does the image invalidates if the asset is removed in the cp? (for example ex-employee wants an image to be removed from the web)
- Assets cache off:
- Every request for an image will be handled via php - performance/resource problems if traffic increases
- Invalidation issue would presits, as glide caches under storage/statamic/glide ?
In our former cms we had the following concept:
- image urls to public folder with presets in filenames, if the image doesn't exists it was generated once (!), after that it was servered directy
- Invalidation/deletion of all image versions if the image was removed in the cms
Atm i have no idea how to use statamic image handling right - or i just misunderstood some concepts?
Ya, our method had it’s drawbacks too though. Modifications are detached from any system knowledge for one. Craft is an example of someone who does some things right here that’s a mix between two approaches, which is similar In some ways to our new approach in Streams 2. Still fleshing it out. Craft’s performance takes a nose dive however, the more you utilize file variants last I checked. Less of an issue with flat-file DB perhaps.
This is a great list of insights and opportunities to improve asset processing. I opened a new issue that would address the specific presets.
Some design decisions are necessary for an implementation / PR. I'll call the new asset cache method "cache on request"
-
Should "cache on request" replace the old STATAMIC_ASSETS_CACHE=true or come in as additional / optional method?
- If replace: Keep using glide tag even if technically not using glide
- If optional: Add new Tag? Tagname?
-
Image generation params will be passed in the filename. Allow free combinations without preset like w300-h200-mFit and/or preset names in filenames?
-
Image cache clear command needed (is think so)? Command syntax?
-
Invalidation of all image versions if the base asset is deleted?
Most of this is addressed by https://github.com/statamic/cms/pull/6040, which should be coming soon đź‘Ť