Image and video CDN — zorka.cdn
zorka.cdn is a separate module for 1C-Bitrix: Site Management, version 0.2.0. It is documented next to zorka.chat, but is neither part of the chat module nor required for chat to work.
It replaces image origins in the final HTML with the selected CDN origin while retaining the path, query and fragment:
/upload/product.jpg?v=4
→ https://by.cdn.zorka.cloud/upload/product.jpg?v=4
Original files, templates and content records stay unchanged. The CDN fetches and converts images; the Bitrix module only rewrites their URLs. It does not upload image files, provision a CDN service or configure DNS/TLS. Video files are submitted separately by the background worker described below.
Installation
Use self-hosted 1C-Bitrix: Site Management, PHP 8.1+ and UTF-8, while also meeting the requirements of your Bitrix version. The module was tested with PHP 8.3 and main module 26.150.0. Administrator access is required.
- Open Marketplace → Solution catalog in the Bitrix admin panel and find zorka.cdn.
- Install the module through Bitrix Market and follow the installation wizard.
- Confirm zorka.cdn is listed in Marketplace → Installed solutions.
- Open
/bitrix/admin/settings.php?lang=ru&mid=zorka.cdnand select the site. - Review the region, endpoints, image formats, additional origins and excluded paths. New sites start disabled.
- Verify that a real image is available from the selected CDN over HTTPS, then enable rewriting. Clear the composite HTML cache if it is used.
The CDN must serve images at the same paths as the origin site. Its network access, certificates and source configuration are managed separately.
Region per site
| Region | Default endpoint |
|---|---|
| Belarus, BY | https://by.cdn.zorka.cloud |
| Europe, EU | https://eu.cdn.zorka.cloud |
| Russia, RU | https://ru.cdn.zorka.cloud |
The administrator selects a region manually for each site. All visitors to that site receive the same CDN URLs. Site settings are independent. Visitor geolocation, automatic failover and load balancing are not implemented.
All three endpoints can be changed. Use a full HTTPS origin without a path, credentials, query or fragment. A region appearing in the form does not mean its CDN service has already been provisioned.
Other settings
Image formats: jpg jpeg png webp avif bmp by default. BMP is converted by the CDN. When upgrading an existing installation, add bmp to the site settings: saved extension lists are preserved. SVG/ICO/TIFF require separate CDN support. Animated GIF uses the video API; do not add it to the image extensions for ImgTune.
Additional site domains: one host per line, without a protocol or path. The current request host is included automatically. Add your own alternate hosts, such as the www variant; unrelated external images are left alone.
Excluded paths: one absolute path prefix per line. /bitrix/admin/, /bitrix/tools/, /personal/ and /upload/private/ are always excluded. Add every private image directory used by your project: a URL alone does not tell the module whether access requires authorization. Keep protected images out of public CDN caches.
Supported markup
- Ordinary img src, responsive srcset and picture sources.
- Common lazy-load attributes including data-src, data-original, data-lazy-src and data-srcset, plus supported background attributes.
- CSS url() inside style attributes and inline style blocks.
- Video posters, image links, preload, social image metadata and SVG references when their file format is enabled.
- Bitrix resize-cache images whose URLs appear in HTML.
Relative paths and absolute URLs of allowed site origins are supported. The selected CDN origin is not prefixed twice. Data URLs, blob URLs, fragment-only references and PHP image handlers are preserved.
Integration boundaries
Version 0.2.0 does not intercept every possible way of loading an image:
- External CSS files are not rewritten. Adapt background URLs in the template or CSS build.
- JavaScript and JSON are not rewritten. Lazy loading works with already rewritten attributes; URLs constructed later by scripts need a component adapter.
- Pages containing a base element are skipped entirely. Extensionless URLs, unfamiliar lazy-load attributes and special CSS constructs need separate integration.
- Email, exports, mobile applications and composite AJAX inserts are not automatically covered by the HTML tests.
There is no automatic origin fallback on CDN failure. Disable rewriting and clear the composite HTML cache when necessary.
Test gallery
The demo uses 9 technical images in 7 formats, approximately 68 MiB of originals: JPEG, PNG, WebP, AVIF, GIF, BMP and SVG. It includes a transparent PNG and a 3840 × 2160 JPEG, with originals up to 17.8 MiB. PNG/BMP are uncompressed, JPEG uses quality 100, and WebP/AVIF are lossless. These are synthetic test targets, not photographs.
Images load as you scroll. The load-all button enables concurrent loading. Each card displays the actual image URL, pixel dimensions, load status and a link to download the original without CDN processing.
Before and after
- Before: the original file size.
- After: the result size reported by the CDN after the image loads.
- Smaller/larger by …%: the change relative to the original, plus the byte difference.
- Response format: the CDN output format, such as AVIF.
- Without CDN processing: the file remains on the origin site.
- Unavailable: size metadata could not be obtained; this does not mean a zero-byte image or prove the image is broken.
A separate HEAD request reads metadata without downloading the image body again. Sizes describe the image file, excluding transport compression and protocol overhead. One MiB is 1,048,576 bytes; one KiB is 1,024 bytes.
Measurements from the BY test profile on 19 September 2026:
| Input | Before | After | Change |
|---|---|---|---|
| 4K JPEG | 17.80 MiB | 869 KiB | −95.2% |
| PNG | 10.57 MiB | 387.2 KiB | −96.4% |
| BMP | 10.55 MiB | 387.2 KiB | −96.4% |
| Lossless WebP | 62.6 KiB | 62.6 KiB, WebP | 0% |
These results describe a specific synthetic test set and CDN profile, not a guaranteed compression ratio for photographs. The current CDN profile preserves a smaller original WebP when the browser accepts it. Forced AVIF previously increased this example by 519%; that is a historical result. Other files may still grow, and the gallery reports increases explicitly.
Video and animated GIF
Version 0.2.0 integrates the CDN video API for:
- MP4 and MOV variants with an
ftypheader; - WebM and MKV;
- AVI;
- animated GIF.
The CDN needs an Advanced license with video support and its video API enabled. Bitrix needs PHP cURL. Output is H.264/AAC MP4, up to 1920×1080 and 30 fps. GIF is encoded for one cycle with transparency replaced by white; use loop for repeated playback.
Setup
- Create a queue directory outside the website root, writable by the PHP user, with permissions 0700.
- Enable video processing for the selected site and specify that directory.
- Allow specific public directories such as
/upload/media/. Do not include private or authenticated media. - Select balanced or small and enter the server token for the selected HTTPS CDN. An empty password field preserves the existing token; changing the CDN origin requires its corresponding token.
- Run the worker every minute as the website OS user. The settings form shows the command for your webroot and site ID:
php /path/to/site/local/modules/zorka.cdn/tools/video-worker.php /path/to/site s1
HTML rendering registers an eligible local video in the queue. The cron worker submits it to the CDN and downloads the result; page rendering never waits for conversion. Once ready, video src, source src inside video and data-src/data-lazy-src are replaced, with source type updated to video/mp4.
Images load from the CDN domain; ready MP4 files load from your website domain. The CDN performs video conversion, then the plugin stores the MP4 under /upload/zorka-cdn-video/. The API requires a token even to download results, so the token stays on the server and is never sent to the player. The local copy survives CDN job expiration.
Use a video element for animated GIF:
<video controls loop muted playsinline src="/upload/media/animation.gif"></video>
GIF inside img is not changed to MP4. Pending or failed jobs retain the original URL, although browsers cannot play every source container. Reload the page after processing and clear composite HTML caches when used. Settings show recent jobs and provide an explicit retry button for failed jobs.
Per-site plugin limits: 64 MiB input, 128 MiB output, 1,000 records and 2 GiB of ready MP4 files. CDN limits may be stricter. Results are not automatically deleted because existing pages may reference them. HLS/DASH, live streams and arbitrary remote sources are not supported.
Before and after examples
The test gallery includes six moving samples: MP4, MOV, WebM, MKV, AVI and GIF, each four seconds at 480×270. Videos include audio; GIF does not. BY results from 19 September 2026:
| Input | Before | After, MP4 | Change |
|---|---|---|---|
| Lossless MP4 | 1.35 MiB | 287.2 KiB | −79.2% |
| MOV | 3.85 MiB | 274.5 KiB | −93.0% |
| Lossless WebM | 1.18 MiB | 287.3 KiB | −76.3% |
| Lossless MKV | 1.43 MiB | 287.2 KiB | −80.4% |
| Uncompressed AVI | 35.98 MiB | 284.2 KiB | −99.2% |
| Animated GIF | 990.1 KiB | 213.6 KiB | −78.4% |
For video, After is the saved MP4 file size. These are measurements of synthetic media, not guaranteed savings for arbitrary clips. Larger outputs are reported without hiding the increase.
Updating, disabling and removal
Before updating, back up the site and database. Open Marketplace → Solution updates, select zorka.cdn and install its available update through Bitrix Market. Verify the version in Installed solutions. If PHP timestamp checks are disabled, refresh OPcache through your hosting workflow.
Clear composite HTML caches after enabling, disabling, changing the region/endpoints or removing the module. Cached pages can be served without PHP and retain old URLs. Changing an option does not rewrite those stored pages.
Uninstalling unregisters the rewrite handler and retains settings. Original image files and content remain on the site. CDN cache management is separate. Ready MP4 files and video settings are retained on uninstall; remove the cron entry manually when permanently removing the module.
Troubleshooting
| Symptom | Check |
|---|---|
| URL remains unchanged | Selected site, enabled state, extension, allowed origin, exclusions, base element and composite cache |
| CDN image fails | The original file, DNS/TLS, CDN HTTP response, supported inputs and service limits |
| Old region still appears | Clear composite HTML caches and reload the page |
| After-size unavailable | CDN HEAD response and CORS; loading and size measurement are separate operations |
| Converted file is larger | CDN output format/profile; the rewrite module does not choose the smaller representation |
Public image delivery was verified for BY. Public EU/RU readiness and compatibility with your site template need separate validation; local region-switching tests are not a substitute.