From 5328948cad288736330c4312b6603df8e002dd17 Mon Sep 17 00:00:00 2001 From: Hugo Alliaume Date: Tue, 12 Aug 2025 21:58:36 +0200 Subject: [PATCH] [LazyImage] Remove package --- .github/CODEOWNERS | 1 - .github/workflows/unit-tests.yaml | 2 +- pnpm-lock.yaml | 30 -- src/LazyImage/.gitattributes | 7 - .../.github/PULL_REQUEST_TEMPLATE.md | 8 - .../.github/workflows/close-pull-request.yml | 20 -- src/LazyImage/.gitignore | 5 - src/LazyImage/.symfony.bundle.yaml | 3 - src/LazyImage/CHANGELOG.md | 55 ---- src/LazyImage/LICENSE | 19 -- src/LazyImage/README.md | 45 --- src/LazyImage/assets/LICENSE | 19 -- src/LazyImage/assets/README.md | 24 -- src/LazyImage/assets/dist/controller.d.ts | 16 - src/LazyImage/assets/dist/controller.js | 40 --- src/LazyImage/assets/package.json | 51 ---- src/LazyImage/assets/src/controller.ts | 59 ---- src/LazyImage/assets/test/controller.test.ts | 66 ----- src/LazyImage/composer.json | 53 ---- src/LazyImage/doc/index.rst | 273 ------------------ src/LazyImage/phpunit.xml.dist | 32 -- src/LazyImage/src/BlurHash/BlurHash.php | 155 ---------- .../src/BlurHash/BlurHashInterface.php | 30 -- .../src/DependencyInjection/Configuration.php | 39 --- .../LazyImageExtension.php | 115 -------- src/LazyImage/src/LazyImageBundle.php | 29 -- src/LazyImage/src/Twig/BlurHashExtension.php | 33 --- src/LazyImage/src/Twig/BlurHashRuntime.php | 38 --- src/LazyImage/tests/BlurHash/BlurHashTest.php | 238 --------------- .../BlurHash/LoggedFetchImageContent.php | 15 - src/LazyImage/tests/Fixtures/logo.png | Bin 8095 -> 0 bytes src/LazyImage/tests/Kernel/AppKernelTrait.php | 41 --- src/LazyImage/tests/Kernel/EmptyAppKernel.php | 35 --- .../tests/Kernel/FrameworkAppKernel.php | 40 --- src/LazyImage/tests/Kernel/TwigAppKernel.php | 44 --- src/LazyImage/tests/LazyImageBundleTest.php | 42 --- src/LazyImage/tests/baseline-ignore | 1 - test_apps/encore-app/assets/controllers.json | 6 - test_apps/encore-app/composer.json | 1 - test_apps/encore-app/config/bundles.php | 1 - .../config/packages/lazy_image.yaml | 16 - test_apps/encore-app/package.json | 1 - test_apps/encore-app/symfony.lock | 12 - ux.symfony.com/assets/controllers.json | 6 - ux.symfony.com/composer.json | 1 - ux.symfony.com/composer.lock | 83 +----- ux.symfony.com/config/bundles.php | 1 - .../UxPackage/LazyImageController.php | 2 - .../src/Service/UxPackageRepository.php | 1 + ux.symfony.com/symfony.lock | 3 - .../ux_packages/lazy_image.html.twig | 99 ++++--- ux.symfony.com/tests/baseline-ignore | 1 - 52 files changed, 56 insertions(+), 1901 deletions(-) delete mode 100644 src/LazyImage/.gitattributes delete mode 100644 src/LazyImage/.github/PULL_REQUEST_TEMPLATE.md delete mode 100644 src/LazyImage/.github/workflows/close-pull-request.yml delete mode 100644 src/LazyImage/.gitignore delete mode 100644 src/LazyImage/.symfony.bundle.yaml delete mode 100644 src/LazyImage/CHANGELOG.md delete mode 100644 src/LazyImage/LICENSE delete mode 100644 src/LazyImage/README.md delete mode 100644 src/LazyImage/assets/LICENSE delete mode 100644 src/LazyImage/assets/README.md delete mode 100644 src/LazyImage/assets/dist/controller.d.ts delete mode 100644 src/LazyImage/assets/dist/controller.js delete mode 100644 src/LazyImage/assets/package.json delete mode 100644 src/LazyImage/assets/src/controller.ts delete mode 100644 src/LazyImage/assets/test/controller.test.ts delete mode 100644 src/LazyImage/composer.json delete mode 100644 src/LazyImage/doc/index.rst delete mode 100644 src/LazyImage/phpunit.xml.dist delete mode 100644 src/LazyImage/src/BlurHash/BlurHash.php delete mode 100644 src/LazyImage/src/BlurHash/BlurHashInterface.php delete mode 100644 src/LazyImage/src/DependencyInjection/Configuration.php delete mode 100644 src/LazyImage/src/DependencyInjection/LazyImageExtension.php delete mode 100644 src/LazyImage/src/LazyImageBundle.php delete mode 100644 src/LazyImage/src/Twig/BlurHashExtension.php delete mode 100644 src/LazyImage/src/Twig/BlurHashRuntime.php delete mode 100644 src/LazyImage/tests/BlurHash/BlurHashTest.php delete mode 100644 src/LazyImage/tests/Fixtures/BlurHash/LoggedFetchImageContent.php delete mode 100644 src/LazyImage/tests/Fixtures/logo.png delete mode 100644 src/LazyImage/tests/Kernel/AppKernelTrait.php delete mode 100644 src/LazyImage/tests/Kernel/EmptyAppKernel.php delete mode 100644 src/LazyImage/tests/Kernel/FrameworkAppKernel.php delete mode 100644 src/LazyImage/tests/Kernel/TwigAppKernel.php delete mode 100644 src/LazyImage/tests/LazyImageBundleTest.php delete mode 100644 src/LazyImage/tests/baseline-ignore delete mode 100644 test_apps/encore-app/config/packages/lazy_image.yaml diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 7e3e86a1ccf..bae7ca3e5c4 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1,4 +1,3 @@ -src/LazyImage @Kocal src/Map @Kocal src/Toolkit @Kocal src/Translator @Kocal diff --git a/.github/workflows/unit-tests.yaml b/.github/workflows/unit-tests.yaml index 8f290331da6..31ddde559ec 100644 --- a/.github/workflows/unit-tests.yaml +++ b/.github/workflows/unit-tests.yaml @@ -73,7 +73,7 @@ jobs: # Exclude deprecated packages when testing against lowest dependencies if [ "${{ matrix.dependency-version }}" = "lowest" ]; then - EXCLUDED_PACKAGES="$EXCLUDED_PACKAGES|LazyImage|TogglePassword" + EXCLUDED_PACKAGES="$EXCLUDED_PACKAGES|TogglePassword" fi PACKAGES=$(find src/ -mindepth 2 -type f -name composer.json -not -path "*/vendor/*" -printf '%h\n' | sed 's/^src\///' | grep -Ev "$EXCLUDED_PACKAGES" | sort | tr '\n' ' ') diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 9a1f99a086e..bc0f84fa513 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -179,36 +179,6 @@ importers: specifier: ^3.2.4 version: 3.2.4(@types/node@22.16.5)(@vitest/browser@3.2.4)(jsdom@26.1.0)(lightningcss@1.30.1)(msw@2.10.4(@types/node@22.16.5)(typescript@5.8.3))(terser@5.43.1) - src/LazyImage/assets: - devDependencies: - '@hotwired/stimulus': - specifier: ^3.0.0 - version: 3.2.2 - '@testing-library/dom': - specifier: ^10.4.0 - version: 10.4.0 - '@testing-library/jest-dom': - specifier: ^6.6.3 - version: 6.6.3 - '@testing-library/user-event': - specifier: ^14.6.1 - version: 14.6.1(@testing-library/dom@10.4.0) - jsdom: - specifier: ^26.1.0 - version: 26.1.0 - tslib: - specifier: ^2.8.1 - version: 2.8.1 - tsx: - specifier: ^4.20.3 - version: 4.20.3 - typescript: - specifier: ^5.8.3 - version: 5.8.3 - vitest: - specifier: ^3.2.4 - version: 3.2.4(@types/node@22.16.5)(@vitest/browser@3.2.4)(jsdom@26.1.0)(lightningcss@1.30.1)(msw@2.10.4(@types/node@22.16.5)(typescript@5.8.3))(terser@5.43.1) - src/LiveComponent/assets: devDependencies: '@hotwired/stimulus': diff --git a/src/LazyImage/.gitattributes b/src/LazyImage/.gitattributes deleted file mode 100644 index b9bb8f6e796..00000000000 --- a/src/LazyImage/.gitattributes +++ /dev/null @@ -1,7 +0,0 @@ -/.git* export-ignore -/.symfony.bundle.yaml export-ignore -/assets/src export-ignore -/assets/test export-ignore -/doc export-ignore -/phpunit.xml.dist export-ignore -/tests export-ignore diff --git a/src/LazyImage/.github/PULL_REQUEST_TEMPLATE.md b/src/LazyImage/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index df3b474b452..00000000000 --- a/src/LazyImage/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,8 +0,0 @@ -Please do not submit any Pull Requests here. They will be closed. ---- - -Please submit your PR here instead: -https://github.com/symfony/ux - -This repository is what we call a "subtree split": a read-only subset of that main repository. -We're looking forward to your PR there! diff --git a/src/LazyImage/.github/workflows/close-pull-request.yml b/src/LazyImage/.github/workflows/close-pull-request.yml deleted file mode 100644 index 57e4e3fb074..00000000000 --- a/src/LazyImage/.github/workflows/close-pull-request.yml +++ /dev/null @@ -1,20 +0,0 @@ -name: Close Pull Request - -on: - pull_request_target: - types: [opened] - -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thanks for your Pull Request! We love contributions. - - However, you should instead open your PR on the main repository: - https://github.com/symfony/ux - - This repository is what we call a "subtree split": a read-only subset of that main repository. - We're looking forward to your PR there! diff --git a/src/LazyImage/.gitignore b/src/LazyImage/.gitignore deleted file mode 100644 index 2cc9f0231c3..00000000000 --- a/src/LazyImage/.gitignore +++ /dev/null @@ -1,5 +0,0 @@ -/assets/node_modules/ -/vendor/ -/composer.lock -/phpunit.xml -/.phpunit.result.cache diff --git a/src/LazyImage/.symfony.bundle.yaml b/src/LazyImage/.symfony.bundle.yaml deleted file mode 100644 index 6d9a74acb76..00000000000 --- a/src/LazyImage/.symfony.bundle.yaml +++ /dev/null @@ -1,3 +0,0 @@ -branches: ["2.x"] -maintained_branches: ["2.x"] -doc_dir: "doc" diff --git a/src/LazyImage/CHANGELOG.md b/src/LazyImage/CHANGELOG.md deleted file mode 100644 index 694aa1b60ca..00000000000 --- a/src/LazyImage/CHANGELOG.md +++ /dev/null @@ -1,55 +0,0 @@ -# CHANGELOG - -## 2.29.0 - -- Add Symfony 8 support - -## 2.26.0 - -- Deprecate the package - -## 2.17.0 - -- Add support for `intervention/image` 3.0+ - -## 2.13.2 - -- Revert "Change JavaScript package to `type: module`" - -## 2.13.0 - -- Add Symfony 7 support. -- Change JavaScript package to `type: module` - -## 2.9.0 - -- Add support for symfony/asset-mapper - -- Minimum required Symfony version is now 5.4 - -## 2.7.0 - -- The JavaScript events now bubble up. - -- Add `assets/src` to `.gitattributes` to exclude source TypeScript files from - installing. - -- TypeScript types are now included. - -## 2.6.0 - -- [BC BREAK] The `assets/` directory was moved from `Resources/assets/` to `assets/`. Make - sure the path in your `package.json` file is updated accordingly. - -- The directory structure of the bundle was updated to match modern best-practices. - -## 2.0 - -- Support for `stimulus` version 2 was removed and support for `@hotwired/stimulus` - version 3 was added. See the [@symfony/stimulus-bridge CHANGELOG](https://github.com/symfony/stimulus-bridge/blob/main/CHANGELOG.md#300) - for more details. -- The `data-hd-src` attribute was changed to use a Stimulus value called `src`. See the - updated README for usage. -- For both JavaScript events - `lazy-image:connect` and `lazy-image:ready` - - the `event.detail.hd` `Image` instance was moved to `event.detail.image`. -- Support added for Symfony 6 diff --git a/src/LazyImage/LICENSE b/src/LazyImage/LICENSE deleted file mode 100644 index 0ed3a246553..00000000000 --- a/src/LazyImage/LICENSE +++ /dev/null @@ -1,19 +0,0 @@ -Copyright (c) 2020-present Fabien Potencier - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is furnished -to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/src/LazyImage/README.md b/src/LazyImage/README.md deleted file mode 100644 index 2578b75bfac..00000000000 --- a/src/LazyImage/README.md +++ /dev/null @@ -1,45 +0,0 @@ -# Symfony UX LazyImage - -> [!WARNING] -> **Deprecated**: This package has been **deprecated** in 2.x and will be removed in the next major version. - -The package has been deprecated in favor of [modern techniques to improve image loading performance](https://web.dev/learn/images/performance-issues) natively supported -by all major browsers (``). - -To keep using BlurHash functionality, you can use the package [kornrunner/php-blurhash](https://github.com/kornrunner/php-blurhash). - ---- - -Symfony UX LazyImage is a Symfony bundle providing utilities to improve -image loading performance. It is part of [the Symfony UX initiative](https://ux.symfony.com/). - -It provides two key features: - -- a Stimulus controller to load lazily heavy images, with a placeholder -- a [BlurHash implementation](https://blurha.sh/) to create data-uri thumbnails for images - -**This repository is a READ-ONLY sub-tree split**. See -https://github.com/symfony/ux to create issues or submit pull requests. - -## Sponsor - -The Symfony UX packages are [backed][1] by [Mercure.rocks][2]. - -Create real-time experiences in minutes! Mercure.rocks provides a realtime API service -that is tightly integrated with Symfony: create UIs that update in live with UX Turbo, -send notifications with the Notifier component, expose async APIs with API Platform and -create low level stuffs with the Mercure component. We maintain and scale the complex -infrastructure for you! - -Help Symfony by [sponsoring][3] its development! - -## Resources - -- [Documentation](https://symfony.com/bundles/ux-lazy-image/current/index.html) -- [Report issues](https://github.com/symfony/ux/issues) and - [send Pull Requests](https://github.com/symfony/ux/pulls) - in the [main Symfony UX repository](https://github.com/symfony/ux) - -[1]: https://symfony.com/backers -[2]: https://mercure.rocks -[3]: https://symfony.com/sponsor diff --git a/src/LazyImage/assets/LICENSE b/src/LazyImage/assets/LICENSE deleted file mode 100644 index 0ed3a246553..00000000000 --- a/src/LazyImage/assets/LICENSE +++ /dev/null @@ -1,19 +0,0 @@ -Copyright (c) 2020-present Fabien Potencier - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is furnished -to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/src/LazyImage/assets/README.md b/src/LazyImage/assets/README.md deleted file mode 100644 index cb8d1cbd6ff..00000000000 --- a/src/LazyImage/assets/README.md +++ /dev/null @@ -1,24 +0,0 @@ -# @symfony/ux-lazy-image - -JavaScript assets of the [symfony/ux-lazy-image](https://packagist.org/packages/symfony/ux-lazy-image) PHP package. - -## Installation - -This npm package is **reserved for advanced users** who want to decouple their JavaScript dependencies from their PHP dependencies (e.g., when building Docker images, running JavaScript-only pipelines, etc.). - -We **strongly recommend not installing this package directly**, but instead install the PHP package [symfony/ux-lazy-image](https://packagist.org/packages/symfony/ux-lazy-image) in your Symfony application with [Flex](https://github.com/symfony/flex) enabled. - -If you still want to install this package directly, please make sure its version exactly matches [symfony/ux-lazy-image](https://packagist.org/packages/symfony/ux-lazy-image) PHP package version: -```shell -composer require symfony/ux-lazy-image:2.23.0 -npm add @symfony/ux-lazy-image@2.23.0 -``` - -**Tip:** Your `package.json` file will be automatically modified by [Flex](https://github.com/symfony/flex) when installing or upgrading a PHP package. To prevent this behavior, ensure to **use at least Flex 1.22.0 or 2.5.0**, and run `composer config extra.symfony.flex.synchronize_package_json false`. - -## Resources - -- [Documentation](https://symfony.com/bundles/ux-lazy-image/current/index.html) -- [Report issues](https://github.com/symfony/ux/issues) and - [send Pull Requests](https://github.com/symfony/ux/pulls) - in the [main Symfony UX repository](https://github.com/symfony/ux) diff --git a/src/LazyImage/assets/dist/controller.d.ts b/src/LazyImage/assets/dist/controller.d.ts deleted file mode 100644 index d9d7c804eb6..00000000000 --- a/src/LazyImage/assets/dist/controller.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { Controller } from '@hotwired/stimulus'; - -declare class export_default extends Controller { - readonly srcValue: string; - readonly srcsetValue: any; - readonly hasSrcsetValue: boolean; - static values: { - src: StringConstructor; - srcset: ObjectConstructor; - }; - connect(): void; - _calculateSrcsetString(): string; - private dispatchEvent; -} - -export { export_default as default }; diff --git a/src/LazyImage/assets/dist/controller.js b/src/LazyImage/assets/dist/controller.js deleted file mode 100644 index c1cabdcd0a8..00000000000 --- a/src/LazyImage/assets/dist/controller.js +++ /dev/null @@ -1,40 +0,0 @@ -// src/controller.ts -import { Controller } from "@hotwired/stimulus"; -var controller_default = class extends Controller { - connect() { - const hd = new Image(); - const element = this.element; - const srcsetString = this._calculateSrcsetString(); - hd.addEventListener("load", () => { - element.src = this.srcValue; - if (srcsetString) { - element.srcset = srcsetString; - } - this.dispatchEvent("ready", { image: hd }); - }); - hd.src = this.srcValue; - if (srcsetString) { - hd.srcset = srcsetString; - } - this.dispatchEvent("connect", { image: hd }); - } - _calculateSrcsetString() { - if (!this.hasSrcsetValue) { - return ""; - } - const sets = Object.keys(this.srcsetValue).map((size) => { - return `${this.srcsetValue[size]} ${size}`; - }); - return sets.join(", ").trimEnd(); - } - dispatchEvent(name, payload) { - this.dispatch(name, { detail: payload, prefix: "lazy-image" }); - } -}; -controller_default.values = { - src: String, - srcset: Object -}; -export { - controller_default as default -}; diff --git a/src/LazyImage/assets/package.json b/src/LazyImage/assets/package.json deleted file mode 100644 index 10cf4347e88..00000000000 --- a/src/LazyImage/assets/package.json +++ /dev/null @@ -1,51 +0,0 @@ -{ - "name": "@symfony/ux-lazy-image", - "description": "Lazy image loader and utilities for Symfony", - "license": "MIT", - "version": "2.29.1", - "keywords": [ - "symfony-ux" - ], - "homepage": "https://ux.symfony.com/lazy-image", - "repository": "https://github.com/symfony/ux-lazy-image", - "type": "module", - "files": [ - "dist" - ], - "main": "dist/controller.js", - "types": "dist/controller.d.ts", - "scripts": { - "build": "tsx ../../../bin/build_package.ts .", - "watch": "tsx ../../../bin/build_package.ts . --watch", - "test": "../../../bin/test_package.sh .", - "check": "biome check", - "ci": "biome ci" - }, - "symfony": { - "controllers": { - "lazy-image": { - "main": "dist/controller.js", - "webpackMode": "eager", - "fetch": "eager", - "enabled": true - } - }, - "importmap": { - "@hotwired/stimulus": "^3.0.0" - } - }, - "peerDependencies": { - "@hotwired/stimulus": "^3.0.0" - }, - "devDependencies": { - "@hotwired/stimulus": "^3.0.0", - "@testing-library/dom": "^10.4.0", - "@testing-library/jest-dom": "^6.6.3", - "@testing-library/user-event": "^14.6.1", - "jsdom": "^26.1.0", - "tslib": "^2.8.1", - "tsx": "^4.20.3", - "typescript": "^5.8.3", - "vitest": "^3.2.4" - } -} diff --git a/src/LazyImage/assets/src/controller.ts b/src/LazyImage/assets/src/controller.ts deleted file mode 100644 index bef9380e738..00000000000 --- a/src/LazyImage/assets/src/controller.ts +++ /dev/null @@ -1,59 +0,0 @@ -/* - * This file is part of the Symfony package. - * - * (c) Fabien Potencier - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -import { Controller } from '@hotwired/stimulus'; - -export default class extends Controller { - declare readonly srcValue: string; - declare readonly srcsetValue: any; - declare readonly hasSrcsetValue: boolean; - - static values = { - src: String, - srcset: Object, - }; - - connect() { - const hd = new Image(); - const element = this.element as HTMLImageElement; - - const srcsetString = this._calculateSrcsetString(); - - hd.addEventListener('load', () => { - element.src = this.srcValue; - if (srcsetString) { - element.srcset = srcsetString; - } - this.dispatchEvent('ready', { image: hd }); - }); - - hd.src = this.srcValue; - if (srcsetString) { - hd.srcset = srcsetString; - } - - this.dispatchEvent('connect', { image: hd }); - } - - _calculateSrcsetString(): string { - if (!this.hasSrcsetValue) { - return ''; - } - - const sets = Object.keys(this.srcsetValue).map((size: string) => { - return `${this.srcsetValue[size]} ${size}`; - }); - - return sets.join(', ').trimEnd(); - } - - private dispatchEvent(name: string, payload: any) { - this.dispatch(name, { detail: payload, prefix: 'lazy-image' }); - } -} diff --git a/src/LazyImage/assets/test/controller.test.ts b/src/LazyImage/assets/test/controller.test.ts deleted file mode 100644 index fa6737e756e..00000000000 --- a/src/LazyImage/assets/test/controller.test.ts +++ /dev/null @@ -1,66 +0,0 @@ -/* - * This file is part of the Symfony package. - * - * (c) Fabien Potencier - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -import { Application, Controller } from '@hotwired/stimulus'; -import { getByTestId, waitFor } from '@testing-library/dom'; -import { afterEach, beforeEach, describe, expect, it } from 'vitest'; -import { clearDOM, mountDOM } from '../../../../test/stimulus-helpers'; -import LazyImageController from '../src/controller'; - -// Controller used to check the actual controller was properly booted -class CheckController extends Controller { - connect() { - this.element.addEventListener('lazy-image:connect', (event) => { - // the Image won't natively have its "load" method in this test - // so we trigger it manually, to "fake" the Image loading. - event.detail.image.dispatchEvent(new Event('load')); - this.element.classList.add('connected'); - }); - } -} - -const startStimulus = () => { - const application = Application.start(); - application.register('check', CheckController); - application.register('lazy-image', LazyImageController); -}; - -describe('LazyImageController', () => { - let container: HTMLElement; - - beforeEach(() => { - container = mountDOM(` - - `); - }); - - afterEach(() => { - clearDOM(); - }); - - it('connect', async () => { - const img = getByTestId(container, 'img'); - expect(img).not.toHaveClass('connected'); - expect(img).toHaveAttribute('src', 'https://symfony.com/logos/symfony_black_02.png'); - - startStimulus(); - await waitFor(() => expect(img).toHaveClass('connected')); - expect(img).toHaveAttribute('src', 'https://symfony.com/logos/symfony_black_03.png'); - expect(img).toHaveAttribute( - 'srcset', - 'https://symfony.com/logos/symfony_black_03.png 1x, https://symfony.com/logos/symfony_black_03_2x.png 2x' - ); - }); -}); diff --git a/src/LazyImage/composer.json b/src/LazyImage/composer.json deleted file mode 100644 index 4eef83304ef..00000000000 --- a/src/LazyImage/composer.json +++ /dev/null @@ -1,53 +0,0 @@ -{ - "name": "symfony/ux-lazy-image", - "type": "symfony-bundle", - "description": "Lazy image loader and utilities for Symfony", - "keywords": [ - "symfony-ux" - ], - "homepage": "https://symfony.com", - "license": "MIT", - "authors": [ - { - "name": "Titouan Galopin", - "email": "galopintitouan@gmail.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "autoload": { - "psr-4": { - "Symfony\\UX\\LazyImage\\": "src/" - } - }, - "autoload-dev": { - "psr-4": { - "Symfony\\UX\\LazyImage\\Tests\\": "tests/" - } - }, - "require": { - "php": ">=8.1", - "symfony/config": "^5.4|^6.0|^7.0|^8.0", - "symfony/http-kernel": "^5.4|^6.0|^7.0|^8.0", - "symfony/dependency-injection": "^5.4|^6.0|^7.0|^8.0", - "symfony/deprecation-contracts": "^2.5|^3" - }, - "require-dev": { - "intervention/image": "^2.5|^3.0", - "kornrunner/blurhash": "^1.1", - "symfony/cache-contracts": "^2.2|^3.0", - "symfony/framework-bundle": "^5.4|^6.0|^7.0|^8.0", - "symfony/phpunit-bridge": "^5.2|^6.0|^7.0|^8.0", - "symfony/twig-bundle": "^5.4|^6.0|^7.0|^8.0", - "symfony/var-dumper": "^5.4|^6.0|^7.0|^8.0" - }, - "extra": { - "thanks": { - "name": "symfony/ux", - "url": "https://github.com/symfony/ux" - } - }, - "minimum-stability": "dev" -} diff --git a/src/LazyImage/doc/index.rst b/src/LazyImage/doc/index.rst deleted file mode 100644 index fd767d0024e..00000000000 --- a/src/LazyImage/doc/index.rst +++ /dev/null @@ -1,273 +0,0 @@ -Symfony UX LazyImage -==================== - -.. warning:: - - **This package is no longer recommended.** Instead, use the - `modern techniques to improve image loading performance`_ natively supported - by all major browsers. - -.. warning:: - - **Deprecated: This package has been deprecated in 2.x and will be removed in the next major version.** - -Symfony UX LazyImage is a Symfony bundle providing utilities to improve -image loading performance. It is part of `the Symfony UX initiative`_. - -It provides two key features: - -- a Stimulus controller to load lazily heavy images, with a placeholder -- a `BlurHash implementation`_ to create data-uri thumbnails for images - -Installation ------------- - -.. caution:: - - Before you start, make sure you have `StimulusBundle configured in your app`_. - -Install the bundle using Composer and Symfony Flex: - -.. code-block:: terminal - - $ composer require symfony/ux-lazy-image - -If you're using WebpackEncore, install your assets and restart Encore (not -needed if you're using AssetMapper): - -.. code-block:: terminal - - $ npm install --force - $ npm run watch - -.. note:: - - For more complex installation scenarios, you can install the JavaScript assets through the `@symfony/ux-lazy-image npm package`_ - -Usage ------ - -The default usage of Symfony UX LazyImage is to use its Stimulus -controller to first load a small placeholder image that will then be -replaced by the high-definition version once the page has been rendered: - -.. code-block:: html+twig - - - -With this setup, the user will initially see ``images/small.png``. Then, -once the page has loaded and the user's browser has downloaded the -larger image, the ``src`` attribute will change to ``image/large.png``. - -There is also support for the ``srcset`` attribute by passing an -``srcset`` value to the controller: - -.. code-block:: html+twig - - - -.. note:: - - The ``stimulus_controller()`` function comes from `StimulusBundle`_. - -Instead of using a generated thumbnail that would exist on your -filesystem, you can use the BlurHash algorithm to create a light, -blurred, data-uri thumbnail of the image: - -.. code-block:: html+twig - - - -The ``data_uri_thumbnail`` function receives 3 arguments: - -- the path to the image to generate the data-uri thumbnail for ; -- the width of the BlurHash to generate -- the height of the BlurHash to generate - -Customizing images fetching -~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -By default, ``data_uri_thumbnail`` fetches images using the `file_get_contents`_ function. -It works well for local files, but you may want to customize it to fetch images from a remote server, `Flysystem`_, etc. - -To do so you can create a invokable class, the first argument is the filename to fetch:: - - namespace App\BlurHash; - - class FetchImageContent - { - public function __invoke(string $filename): string - { - // Your custom implementation here to fetch the image content - } - } - -Then you must configure the service in your Symfony configuration: - -.. code-block:: yaml - - # config/packages/lazy_image.yaml - lazy_image: - fetch_image_content: 'App\BlurHash\FetchImageContent' - -Performance considerations -~~~~~~~~~~~~~~~~~~~~~~~~~~ - -You should try to generate small BlurHash images as generating the image -can be CPU-intensive. Instead, you can rely on the browser scaling -abilities by generating a small image and using the ``width`` and -``height`` HTML attributes to scale up the image. - -You can also configure a cache pool to store the generated BlurHash, -this way you can avoid generating the same BlurHash multiple times: - -.. code-block:: yaml - - # config/packages/lazy_image.yaml - framework: - cache: - pools: - cache.lazy_image: cache.adapter.redis # or any other cache adapter depending on your needs - - lazy_image: - cache: cache.lazy_image # the cache pool to use - -Extend the default behavior -~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -Symfony UX LazyImage allows you to extend its default behavior using a -custom Stimulus controller: - -.. code-block:: javascript - - // mylazyimage_controller.js - - import { Controller } from '@hotwired/stimulus'; - - export default class extends Controller { - connect() { - this.element.addEventListener('lazy-image:connect', this._onConnect); - this.element.addEventListener('lazy-image:ready', this._onReady); - } - - disconnect() { - // You should always remove listeners when the controller is disconnected to avoid side-effects - this.element.removeEventListener('lazy-image:connect', this._onConnect); - this.element.removeEventListener('lazy-image:ready', this._onReady); - } - - _onConnect(event) { - // The lazy-image behavior just started - } - - _onReady(event) { - // The HD version has just been loaded - } - } - -Then in your template, add your controller to the HTML attribute: - -.. code-block:: html+twig - - - -.. - - **Note**: be careful to add your controller **before** the LazyImage - controller so that it is executed before and can listen on the - ``lazy-image:connect`` event properly. - -Largest Contentful Paint (LCP) and Web performance considerations -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -The `Largest Contentful Paint (LCP)`_ is a key metric for web performance. -It measures the time it takes for the largest image or text block to be rendered -on the page and should be less than 2.5 seconds. It's part of the `Core Web Vitals`_ -and is used by Google to evaluate the user experience of a website, impacting -the Search ranking. - -Using the Symfony UX LazyImage for your LCP image can be a good idea at first, -but in reality, it will lower the LCP score because: - -- `The progressive loading (through blurhash) is not taken into account in the LCP calculation`_; -- Even if you eagerly load the LazyImage Stimulus controller, a small delay will - be added to the LCP calculation; -- If you `didn't preload the image`_, the browser will wait for the Stimulus - controller to load the image, which adds another delay to the LCP calculation. - -A solution is to not use the Stimulus controller for the LCP image but to use -``src`` and ``style`` attributes instead, and preload the image as well: - -.. code-block:: html+twig - - - -This way, the browser will display the BlurHash image as soon as possible, and -will load the high-definition image at the same time, without waiting for the -Stimulus controller to be loaded. - -Backward Compatibility promise ------------------------------- - -This bundle aims at following the same Backward Compatibility promise as -the Symfony framework: -https://symfony.com/doc/current/contributing/code/bc.html - -.. _`modern techniques to improve image loading performance`: https://web.dev/learn/images/performance-issues -.. _`the Symfony UX initiative`: https://ux.symfony.com/ -.. _`BlurHash implementation`: https://blurha.sh -.. _`StimulusBundle`: https://symfony.com/bundles/StimulusBundle/current/index.html -.. _StimulusBundle configured in your app: https://symfony.com/bundles/StimulusBundle/current/index.html -.. _`file_get_contents`: https://www.php.net/manual/en/function.file-get-contents.php -.. _`Flysystem`: https://flysystem.thephpleague.com -.. _`Largest Contentful Paint (LCP)`: https://web.dev/lcp/ -.. _`Core Web Vitals`: https://web.dev/vitals/ -.. _`The progressive loading (through blurhash) is not taken into account in the LCP calculation`: https://github.com/w3c/largest-contentful-paint/issues/71_ -.. _`didn't preload the image`: https://symfony.com/doc/current/web_link.html -.. _`@symfony/ux-lazy-image npm package`: https://www.npmjs.com/package/@symfony/ux-lazy-image diff --git a/src/LazyImage/phpunit.xml.dist b/src/LazyImage/phpunit.xml.dist deleted file mode 100644 index 6fdeff61bf4..00000000000 --- a/src/LazyImage/phpunit.xml.dist +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - - - - - - - ./tests - - - - - - ./src - - - - - - - diff --git a/src/LazyImage/src/BlurHash/BlurHash.php b/src/LazyImage/src/BlurHash/BlurHash.php deleted file mode 100644 index 6778e029f0d..00000000000 --- a/src/LazyImage/src/BlurHash/BlurHash.php +++ /dev/null @@ -1,155 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\UX\LazyImage\BlurHash; - -use Intervention\Image\Colors\Rgb\Color; -use Intervention\Image\Drivers\Gd\Encoders\JpegEncoder; -use Intervention\Image\ImageManager; -use Intervention\Image\ImageManagerStatic; -use kornrunner\Blurhash\Blurhash as BlurhashEncoder; -use Symfony\Contracts\Cache\CacheInterface; - -trigger_deprecation('symfony/ux-lazy-image', '2.27.0', 'The package is deprecated and will be removed in 3.0.'); - -/** - * @author Titouan Galopin - * - * @final - */ -class BlurHash implements BlurHashInterface -{ - private \Closure $fetchImageContent; - - /** - * @param (callable(string): string)|null $fetchImageContent - */ - public function __construct( - private ?ImageManager $imageManager = null, - private ?CacheInterface $cache = null, - ?callable $fetchImageContent = null, - ) { - $this->fetchImageContent = $fetchImageContent ? $fetchImageContent(...) : file_get_contents(...); - } - - public static function intervention3(): bool - { - return !class_exists(ImageManagerStatic::class); - } - - public function createDataUriThumbnail(string $filename, int $width, int $height, int $encodingWidth = 75, int $encodingHeight = 75): string - { - // Resize and encode - $encoded = $this->encode($filename, $encodingWidth, $encodingHeight); - - // Create a new blurred thumbnail from encoded BlurHash - $pixels = BlurhashEncoder::decode($encoded, $width, $height); - - return $this->encodeImage($pixels, $width, $height); - } - - public function encode(string $filename, int $encodingWidth = 75, int $encodingHeight = 75): string - { - if ($this->cache) { - return $this->cache->get( - 'blurhash.'.hash('xxh3', $filename.$encodingWidth.$encodingHeight), - fn () => $this->doEncode($filename, $encodingWidth, $encodingHeight) - ); - } - - return $this->doEncode($filename, $encodingWidth, $encodingHeight); - } - - private function doEncode(string $filename, int $encodingWidth = 75, int $encodingHeight = 75): string - { - if (!$this->imageManager) { - throw new \LogicException('To use the Blurhash feature, install intervention/image.'); - } - - if (!class_exists(BlurhashEncoder::class)) { - throw new \LogicException('To use the Blurhash feature, install kornrunner/blurhash.'); - } - - return BlurhashEncoder::encode($this->generatePixels($filename, $encodingWidth, $encodingHeight), 4, 3); - } - - private function generatePixels(string $filename, int $encodingWidth, int $encodingHeight): array - { - $imageContent = ($this->fetchImageContent)($filename); - - if (self::intervention3()) { - $image = $this->imageManager->read($imageContent)->scale($encodingWidth, $encodingHeight); - $width = $image->width(); - $height = $image->height(); - $pixels = []; - - for ($y = 0; $y < $height; ++$y) { - $row = []; - for ($x = 0; $x < $width; ++$x) { - $row[] = $image->pickColor($x, $y)->toArray(); - } - - $pixels[] = $row; - } - - return $pixels; - } - - // Resize image to increase encoding performance - $image = $this->imageManager->make($imageContent); - $image->resize($encodingWidth, $encodingHeight, static function ($constraint) { - $constraint->aspectRatio(); - $constraint->upsize(); - }); - - // Encode using BlurHash - $width = $image->getWidth(); - $height = $image->getHeight(); - $pixels = []; - - for ($y = 0; $y < $height; ++$y) { - $row = []; - for ($x = 0; $x < $width; ++$x) { - $color = $image->pickColor($x, $y); - $row[] = [$color[0], $color[1], $color[2]]; - } - - $pixels[] = $row; - } - - return $pixels; - } - - private function encodeImage(array $pixels, int $width, int $height): string - { - if (self::intervention3()) { - $thumbnail = $this->imageManager->create($width, $height); - - for ($y = 0; $y < $height; ++$y) { - for ($x = 0; $x < $width; ++$x) { - $thumbnail->drawPixel($x, $y, new Color($pixels[$y][$x][0], $pixels[$y][$x][1], $pixels[$y][$x][2])); - } - } - - return $thumbnail->encode(new JpegEncoder(80))->toDataUri(); - } - - $thumbnail = $this->imageManager->canvas($width, $height); - - for ($y = 0; $y < $height; ++$y) { - for ($x = 0; $x < $width; ++$x) { - $thumbnail->pixel($pixels[$y][$x], $x, $y); - } - } - - return 'data:image/jpeg;base64,'.base64_encode($thumbnail->encode('jpg', 80)); - } -} diff --git a/src/LazyImage/src/BlurHash/BlurHashInterface.php b/src/LazyImage/src/BlurHash/BlurHashInterface.php deleted file mode 100644 index aaad364b580..00000000000 --- a/src/LazyImage/src/BlurHash/BlurHashInterface.php +++ /dev/null @@ -1,30 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\UX\LazyImage\BlurHash; - -trigger_deprecation('symfony/ux-lazy-image', '2.27.0', 'The package is deprecated and will be removed in 3.0.'); - -/** - * @author Titouan Galopin - */ -interface BlurHashInterface -{ - /** - * Create and return a blurred thumbnail of the given image encoded as data URI. - */ - public function createDataUriThumbnail(string $filename, int $width, int $height, int $encodingWidth = 75, int $encodingHeight = 75): string; - - /** - * Encode the given image using the BlurHash algorithm. - */ - public function encode(string $filename, int $encodingWidth = 75, int $encodingHeight = 75): string; -} diff --git a/src/LazyImage/src/DependencyInjection/Configuration.php b/src/LazyImage/src/DependencyInjection/Configuration.php deleted file mode 100644 index 9e4927d674e..00000000000 --- a/src/LazyImage/src/DependencyInjection/Configuration.php +++ /dev/null @@ -1,39 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\UX\LazyImage\DependencyInjection; - -use Symfony\Component\Config\Definition\Builder\TreeBuilder; -use Symfony\Component\Config\Definition\ConfigurationInterface; - -trigger_deprecation('symfony/ux-lazy-image', '2.27.0', 'The package is deprecated and will be removed in 3.0.'); - -/** - * @author Hugo Alliaume - * - * @internal - */ -final class Configuration implements ConfigurationInterface -{ - public function getConfigTreeBuilder(): TreeBuilder - { - $treeBuilder = new TreeBuilder('ux_lazy_image'); - $rootNode = $treeBuilder->getRootNode(); - $rootNode - ->children() - ->scalarNode('cache')->end() - ->scalarNode('fetch_image_content')->defaultNull()->end() - ->end() - ; - - return $treeBuilder; - } -} diff --git a/src/LazyImage/src/DependencyInjection/LazyImageExtension.php b/src/LazyImage/src/DependencyInjection/LazyImageExtension.php deleted file mode 100644 index 07981b592be..00000000000 --- a/src/LazyImage/src/DependencyInjection/LazyImageExtension.php +++ /dev/null @@ -1,115 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\UX\LazyImage\DependencyInjection; - -use Intervention\Image\Drivers\Gd\Driver; -use Intervention\Image\ImageManager; -use Symfony\Component\AssetMapper\AssetMapperInterface; -use Symfony\Component\DependencyInjection\ContainerBuilder; -use Symfony\Component\DependencyInjection\ContainerInterface; -use Symfony\Component\DependencyInjection\Definition; -use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface; -use Symfony\Component\DependencyInjection\Reference; -use Symfony\Component\HttpKernel\DependencyInjection\Extension; -use Symfony\UX\LazyImage\BlurHash\BlurHash; -use Symfony\UX\LazyImage\BlurHash\BlurHashInterface; -use Symfony\UX\LazyImage\Twig\BlurHashExtension; -use Symfony\UX\LazyImage\Twig\BlurHashRuntime; - -trigger_deprecation('symfony/ux-lazy-image', '2.27.0', 'The package is deprecated and will be removed in 3.0.'); - -/** - * @author Titouan Galopin - * - * @internal - */ -class LazyImageExtension extends Extension implements PrependExtensionInterface -{ - public function load(array $configs, ContainerBuilder $container): void - { - $configuration = new Configuration(); - $config = $this->processConfiguration($configuration, $configs); - - if (class_exists(ImageManager::class)) { - $container - ->setDefinition('lazy_image.image_manager', new Definition(ImageManager::class)) - ->addArgument(BlurHash::intervention3() ? Driver::class : []) - ; - } - - $container - ->setDefinition('lazy_image.blur_hash', new Definition(BlurHash::class)) - ->setArguments([ - new Reference('lazy_image.image_manager', ContainerInterface::NULL_ON_INVALID_REFERENCE), - null, // $cache - null, // $fetchImageContent - ]) - ; - - if (isset($config['cache'])) { - $container - ->getDefinition('lazy_image.blur_hash') - ->setArgument(1, new Reference($config['cache'])) - ; - } - - if (isset($config['fetch_image_content'])) { - $container - ->getDefinition('lazy_image.blur_hash') - ->setArgument(2, new Reference($config['fetch_image_content'])) - ; - } - - $container->setAlias(BlurHashInterface::class, 'lazy_image.blur_hash')->setPublic(false); - - $container - ->setDefinition('twig.extension.blur_hash', new Definition(BlurHashExtension::class)) - ->addTag('twig.extension') - ; - - $container - ->setDefinition('twig.runtime.blur_hash', new Definition(BlurHashRuntime::class)) - ->addArgument(new Reference('lazy_image.blur_hash')) - ->addTag('twig.runtime') - ; - } - - public function prepend(ContainerBuilder $container): void - { - if (!$this->isAssetMapperAvailable($container)) { - return; - } - - $container->prependExtensionConfig('framework', [ - 'asset_mapper' => [ - 'paths' => [ - __DIR__.'/../../assets/dist' => '@symfony/ux-lazy-image', - ], - ], - ]); - } - - private function isAssetMapperAvailable(ContainerBuilder $container): bool - { - if (!interface_exists(AssetMapperInterface::class)) { - return false; - } - - // check that FrameworkBundle 6.3 or higher is installed - $bundlesMetadata = $container->getParameter('kernel.bundles_metadata'); - if (!isset($bundlesMetadata['FrameworkBundle'])) { - return false; - } - - return is_file($bundlesMetadata['FrameworkBundle']['path'].'/Resources/config/asset_mapper.php'); - } -} diff --git a/src/LazyImage/src/LazyImageBundle.php b/src/LazyImage/src/LazyImageBundle.php deleted file mode 100644 index b39725c98a8..00000000000 --- a/src/LazyImage/src/LazyImageBundle.php +++ /dev/null @@ -1,29 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\UX\LazyImage; - -use Symfony\Component\HttpKernel\Bundle\Bundle; - -trigger_deprecation('symfony/ux-lazy-image', '2.27.0', 'The package is deprecated and will be removed in 3.0.'); - -/** - * @author Titouan Galopin - * - * @final - */ -class LazyImageBundle extends Bundle -{ - public function getPath(): string - { - return \dirname(__DIR__); - } -} diff --git a/src/LazyImage/src/Twig/BlurHashExtension.php b/src/LazyImage/src/Twig/BlurHashExtension.php deleted file mode 100644 index 1b31a2331d3..00000000000 --- a/src/LazyImage/src/Twig/BlurHashExtension.php +++ /dev/null @@ -1,33 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\UX\LazyImage\Twig; - -use Twig\Extension\AbstractExtension; -use Twig\TwigFunction; - -trigger_deprecation('symfony/ux-lazy-image', '2.27.0', 'The package is deprecated and will be removed in 3.0.'); - -/** - * @author Titouan Galopin - * - * @final - */ -class BlurHashExtension extends AbstractExtension -{ - public function getFunctions(): array - { - return [ - new TwigFunction('data_uri_thumbnail', [BlurHashRuntime::class, 'createDataUriThumbnail']), - new TwigFunction('blur_hash', [BlurHashRuntime::class, 'blurHash']), - ]; - } -} diff --git a/src/LazyImage/src/Twig/BlurHashRuntime.php b/src/LazyImage/src/Twig/BlurHashRuntime.php deleted file mode 100644 index 25a96466847..00000000000 --- a/src/LazyImage/src/Twig/BlurHashRuntime.php +++ /dev/null @@ -1,38 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\UX\LazyImage\Twig; - -use Symfony\UX\LazyImage\BlurHash\BlurHashInterface; -use Twig\Extension\RuntimeExtensionInterface; - -trigger_deprecation('symfony/ux-lazy-image', '2.27.0', 'The package is deprecated and will be removed in 3.0.'); - -/** - * @author Hugo Alliaume - */ -final class BlurHashRuntime implements RuntimeExtensionInterface -{ - public function __construct( - private BlurHashInterface $blurHash, - ) { - } - - public function createDataUriThumbnail(string $filename, int $width, int $height, int $encodingWidth = 75, int $encodingHeight = 75): string - { - return $this->blurHash->createDataUriThumbnail($filename, $width, $height, $encodingWidth, $encodingHeight); - } - - public function blurHash(string $filename, int $encodingWidth = 75, int $encodingHeight = 75): string - { - return $this->blurHash->encode($filename, $encodingWidth, $encodingHeight); - } -} diff --git a/src/LazyImage/tests/BlurHash/BlurHashTest.php b/src/LazyImage/tests/BlurHash/BlurHashTest.php deleted file mode 100644 index a5b6fcfc500..00000000000 --- a/src/LazyImage/tests/BlurHash/BlurHashTest.php +++ /dev/null @@ -1,238 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\UX\LazyImage\Tests\BlurHash; - -use PHPUnit\Framework\TestCase; -use Symfony\Component\Cache\Adapter\ArrayAdapter; -use Symfony\Component\Config\Loader\LoaderInterface; -use Symfony\Component\DependencyInjection\ContainerBuilder; -use Symfony\Component\DependencyInjection\Definition; -use Symfony\Contracts\Cache\CacheInterface; -use Symfony\UX\LazyImage\BlurHash\BlurHash; -use Symfony\UX\LazyImage\BlurHash\BlurHashInterface; -use Symfony\UX\LazyImage\Tests\Fixtures\BlurHash\LoggedFetchImageContent; -use Symfony\UX\LazyImage\Tests\Kernel\TwigAppKernel; - -/** - * @author Titouan Galopin - * - * @internal - */ -class BlurHashTest extends TestCase -{ - public function testEncode() - { - $kernel = new TwigAppKernel('test', true); - $kernel->boot(); - $container = $kernel->getContainer()->get('test.service_container'); - - /** @var BlurHashInterface $blurHash */ - $blurHash = $container->get('test.lazy_image.blur_hash'); - - $this->assertSame( - BlurHash::intervention3() ? 'LnMtaO9FD%IU%MRjayRj~qIUM{of' : 'L54ec*~q_3?bofoffQWB9F9FD%IU', - $blurHash->encode(__DIR__.'/../Fixtures/logo.png') - ); - } - - public function testWithCustomGetImageContent() - { - $kernel = new class('test', true) extends TwigAppKernel { - public function registerContainerConfiguration(LoaderInterface $loader): void - { - parent::registerContainerConfiguration($loader); - - $loader->load(static function (ContainerBuilder $container) { - $container->loadFromExtension('lazy_image', [ - 'fetch_image_content' => 'logged_get_image_content', - ]); - - $container - ->setDefinition('logged_get_image_content', new Definition(LoggedFetchImageContent::class)) - ->setPublic('true') - ; - }); - } - }; - - $kernel->boot(); - $container = $kernel->getContainer()->get('test.service_container'); - - /** @var BlurHashInterface $blurHash */ - $blurHash = $container->get('test.lazy_image.blur_hash'); - - $loggedGetImageContent = $container->get('logged_get_image_content'); - $this->assertInstanceOf(LoggedFetchImageContent::class, $loggedGetImageContent); - $this->assertEmpty($loggedGetImageContent->logs); - - $this->assertSame( - BlurHash::intervention3() ? 'LnMtaO9FD%IU%MRjayRj~qIUM{of' : 'L54ec*~q_3?bofoffQWB9F9FD%IU', - $blurHash->encode(__DIR__.'/../Fixtures/logo.png') - ); - - $this->assertCount(1, $loggedGetImageContent->logs); - $this->assertSame(__DIR__.'/../Fixtures/logo.png', $loggedGetImageContent->logs[0]); - } - - public function testEnsureCacheIsNotUsedWhenNotConfigured() - { - $kernel = new TwigAppKernel('test', true); - $kernel->boot(); - $container = $kernel->getContainer()->get('test.service_container'); - - /** @var BlurHashInterface $blurHash */ - $blurHash = $container->get('test.lazy_image.blur_hash'); - - $this->assertInstanceOf(BlurHash::class, $blurHash); - $this->assertNull($this->extractCache($blurHash)); - } - - public function testEnsureCacheIsUsedWhenConfigured() - { - $kernel = new class('test', true) extends TwigAppKernel { - public function registerContainerConfiguration(LoaderInterface $loader): void - { - parent::registerContainerConfiguration($loader); - - $loader->load(static function (ContainerBuilder $container) { - $container->loadFromExtension('framework', [ - 'cache' => [ - 'pools' => [ - 'cache.lazy_image' => [ - 'adapter' => 'cache.adapter.array', - ], - ], - ], - ]); - - $container->loadFromExtension('lazy_image', [ - 'cache' => 'cache.lazy_image', - ]); - - $container->setAlias('test.cache.lazy_image', 'cache.lazy_image')->setPublic(true); - }); - } - }; - - $kernel->boot(); - $container = $kernel->getContainer()->get('test.service_container'); - - /** @var BlurHashInterface $blurHash */ - $blurHash = $container->get('test.lazy_image.blur_hash'); - - $this->assertInstanceOf(BlurHash::class, $blurHash); - $this->assertInstanceOf(CacheInterface::class, $this->extractCache($blurHash)); - } - - public function testCreateDataUriThumbnail() - { - $kernel = new TwigAppKernel('test', true); - $kernel->boot(); - $container = $kernel->getContainer()->get('test.service_container'); - - /** @var BlurHashInterface $blurHash */ - $blurHash = $container->get('test.lazy_image.blur_hash'); - - $this->assertInstanceOf(BlurHash::class, $blurHash); - $this->assertNull($this->extractCache($blurHash)); - - $this->assertSame( - BlurHash::intervention3() ? 'data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEAYABgAAD//gA7Q1JFQVRPUjogZ2QtanBlZyB2MS4wICh1c2luZyBJSkcgSlBFRyB2ODApLCBxdWFsaXR5ID0gODAK/9sAQwAGBAUGBQQGBgUGBwcGCAoQCgoJCQoUDg8MEBcUGBgXFBYWGh0lHxobIxwWFiAsICMmJykqKRkfLTAtKDAlKCko/9sAQwEHBwcKCAoTCgoTKBoWGigoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgo/8AAEQgAOgDqAwEiAAIRAQMRAf/EAB8AAAEFAQEBAQEBAAAAAAAAAAABAgMEBQYHCAkKC//EALUQAAIBAwMCBAMFBQQEAAABfQECAwAEEQUSITFBBhNRYQcicRQygZGhCCNCscEVUtHwJDNicoIJChYXGBkaJSYnKCkqNDU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6g4SFhoeIiYqSk5SVlpeYmZqio6Slpqeoqaqys7S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Vnzyiq812Oeaz7i7HPNAE1xKOeayrqYc81Dd3ygHJrGubxpCQvT1oAde3GThapUHmigAooooAKdG21s02igDUt5gQOavxSCueRyh4q3Dd44NAHQJJUyyVix3QPerC3I9aANTzKDIKzhcj1pDcj1oAvtJULyVSa5HrVeS7A70AXJZBVGeYDPNVpbvPSqruzHk0APmk3HioqKKACiiigD1X7WfWmm7PrVA000AXGuz61C92fWqrVA9AFiS8PrVSa896hlqlP3oAfcX+M81lXF+zkhfzqO8NVKAFd2c5Y5pKKKACiiigAooooAKKKKACiiigBQxHQ08TOO9R0UATfaHpDcOaiooAeZXPemEk9aKKACiiigAooooAKKKKAP/9k=', - $blurHash->createDataUriThumbnail(__DIR__.'/../Fixtures/logo.png', 234, 58) - ); - } - - public function testCreateDataUriThumbnailWithCache() - { - $kernel = new class('test', true) extends TwigAppKernel { - public function registerContainerConfiguration(LoaderInterface $loader): void - { - parent::registerContainerConfiguration($loader); - - $loader->load(static function (ContainerBuilder $container) { - $container->loadFromExtension('framework', [ - 'cache' => [ - 'pools' => [ - 'cache.lazy_image' => [ - 'adapter' => 'cache.adapter.array', - ], - ], - ], - ]); - - $container->loadFromExtension('lazy_image', [ - 'cache' => 'cache.lazy_image', - ]); - - $container->setAlias('test.cache.lazy_image', 'cache.lazy_image')->setPublic(true); - }); - } - }; - - $kernel->boot(); - $container = $kernel->getContainer()->get('test.service_container'); - - /** @var BlurHashInterface $blurHash */ - $blurHash = $container->get('test.lazy_image.blur_hash'); - - $this->assertInstanceOf(BlurHash::class, $blurHash); - $this->assertInstanceOf(ArrayAdapter::class, $cache = $this->extractCache($blurHash)); - - $this->assertEmpty($cache->getValues()); - - $this->assertSame( - BlurHash::intervention3() ? 'data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEAYABgAAD//gA7Q1JFQVRPUjogZ2QtanBlZyB2MS4wICh1c2luZyBJSkcgSlBFRyB2ODApLCBxdWFsaXR5ID0gODAK/9sAQwAGBAUGBQQGBgUGBwcGCAoQCgoJ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qRIXbtQBHRVtLMnrUy2Q9KAM6itQWQ9KDZD0oAy6K0Gsh6VE9oR0oAqUVI8Lr2qMjHWgAooooAKKKKAPov7OPSmm3HpWhgU1gKAM1rcelQPbj0rUcCoJAKAMmSAelVJYB6VsSgVTlAoAxpoR6VRnhHpWzMBWfOBzQBi3EI5rLuYRg8Vu3GOayrnHNAHO3sA5IrPPBravMYNYz/eNACUUUUAFKqljgUlTWwGaALFvbjvV+KAelNgA4q7EBQAiQj0qVYR6VKgqZRQBX8kelBhHpVoCgigCk0I9KheEelaDAVC4FAGZLAKpT249K2JAKpzAUAY0iFTTKuXAHNU6ACiiigD6S84U1phWP9s96abz3oA1XmFQSTCs1rv3qB7v3oA0JZh61TllFUpbv3qpLd+9AFqaUVnzyiq812Oeaz7i7HPNAE1xKOeayrqYc81Dd3ygHJrGubxpCQvT1oAde3GThapUHmigAooooAKdG21s02igDUt5gQOavxSCueRyh4q3Dd44NAHQJJUyyVix3QPerC3I9aANTzKDIKzhcj1pDcj1oAvtJULyVSa5HrVeS7A70AXJZBVGeYDPNVpbvPSqruzHk0APmk3HioqKKACiiigD1X7WfWmm7PrVA000AXGuz61C92fWqrVA9AFiS8PrVSa896hlqlP3oAfcX+M81lXF+zkhfzqO8NVKAFd2c5Y5pKKKACiiigAooooAKKKKACiiigBQxHQ08TOO9R0UATfaHpDcOaiooAeZXPemEk9aKKACiiigAooooAKKKKAP/9k=', - $blurHash->createDataUriThumbnail(__DIR__.'/../Fixtures/logo.png', 234, 58) - ); - - $this->assertNotEmpty($cache->getValues()); - - $this->assertSame( - BlurHash::intervention3() ? 'data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEAYABgAAD//gA7Q1JFQVRPUjogZ2QtanBlZyB2MS4wICh1c2luZyBJSkcgSlBFRyB2ODApLCBxdWFsaXR5ID0gODAK/9sAQwAGBAUGBQQGBgUGBwcGCAoQCgoJCQoUDg8MEBcUGBgXFBYWGh0lHxobIxwWFiAsICMmJykqKRkfLTAtKDAlKC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AqUVI8Lr2qMjHWgAooooAKKKKAPov7OPSmm3HpWhgU1gKAM1rcelQPbj0rUcCoJAKAMmSAelVJYB6VsSgVTlAoAxpoR6VRnhHpWzMBWfOBzQBi3EI5rLuYRg8Vu3GOayrnHNAHO3sA5IrPPBravMYNYz/eNACUUUUAFKqljgUlTWwGaALFvbjvV+KAelNgA4q7EBQAiQj0qVYR6VKgqZRQBX8kelBhHpVoCgigCk0I9KheEelaDAVC4FAGZLAKpT249K2JAKpzAUAY0iFTTKuXAHNU6ACiiigD6S84U1phWP9s96abz3oA1XmFQSTCs1rv3qB7v3oA0JZh61TllFUpbv3qpLd+9AFqaUVnzyiq812Oeaz7i7HPNAE1xKOeayrqYc81Dd3ygHJrGubxpCQvT1oAde3GThapUHmigAooooAKdG21s02igDUt5gQOavxSCueRyh4q3Dd44NAHQJJUyyVix3QPerC3I9aANTzKDIKzhcj1pDcj1oAvtJULyVSa5HrVeS7A70AXJZBVGeYDPNVpbvPSqruzHk0APmk3HioqKKACiiigD1X7WfWmm7PrVA000AXGuz61C92fWqrVA9AFiS8PrVSa896hlqlP3oAfcX+M81lXF+zkhfzqO8NVKAFd2c5Y5pKKKACiiigAooooAKKKKACiiigBQxHQ08TOO9R0UATfaHpDcOaiooAeZXPemEk9aKKACiiigAooooAKKKKAP/9k=', - $blurHash->createDataUriThumbnail(__DIR__.'/../Fixtures/logo.png', 234, 58) - ); - - $this->assertNotEmpty($cache->getValues()); - } - - public function testTwigExtension() - { - $kernel = new TwigAppKernel('test', true); - $kernel->boot(); - $twig = $kernel->getContainer()->get('test.service_container')->get('twig'); - $output = $twig->createTemplate(<<render(['file' => __DIR__.'/../Fixtures/logo.png']); - - if (BlurHash::intervention3()) { - $expected = <<assertSame($expected, $output); - - $kernel->shutdown(); - } - - private function extractCache(BlurHash $blurHash): ?CacheInterface - { - return \Closure::bind(fn () => $this->cache, $blurHash, BlurHash::class)(); - } -} diff --git a/src/LazyImage/tests/Fixtures/BlurHash/LoggedFetchImageContent.php b/src/LazyImage/tests/Fixtures/BlurHash/LoggedFetchImageContent.php deleted file mode 100644 index a49da39c738..00000000000 --- a/src/LazyImage/tests/Fixtures/BlurHash/LoggedFetchImageContent.php +++ /dev/null @@ -1,15 +0,0 @@ -logs[] = $filename; - - return file_get_contents($filename); - } -} diff --git a/src/LazyImage/tests/Fixtures/logo.png b/src/LazyImage/tests/Fixtures/logo.png deleted file mode 100644 index c8278fc1b655c2357451def7f3043600a660031a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 8095 zcmb7J^;Z<$(*`N&?vhkViKV2w%UxJXkd&pnSsH0+>BePgVQF0HMg&%rMoN|sA+U73 zeE)>^{xHuyGtb;JbM8IQx#vuRp}qzw5fc#>78a?Nrm8U(77qMzkA8~tXbY({S02I6 zP#387i2twk@bGYUhS}RgFR!f5%+3uA4Yzf4*3{M&7MG-b%!rJN@$vPycW?rMOx091 zxH!2V4`&Gc5c>!ezQ+1*uqd9rQZ%&jjQCjE^lfJS7`P4_#lm7+(o$6d1}+{H?FQFM zQN-!dKl^C0{HOoUdRx9=&b306ix4;PYf1O>1kzvtr~(Bc8FHRx*zF0)UN02O`TQ?Y zl`|HUA-3wP4ggG01)FmlKOG7hdz}@Sml?^Eu0GTXQ*)|nw7O*u$tLgjp2N>#@_tEL10b27^#~#-!uDkT z$L?`dhb*AZrZr1o@PeYhg`|5pAYU<>B5R(o!Y?&50dghhNI$8tHPVOt*>9&h36;`z zv=7#_c0t;9fu8y5c{~1#jccuPtF1iD+JaM%JX(Z(89;o4ta(oFS=E`8$Aa;JP?z|t z-k#1Ej`fgnF}Xs#4k`qwa zoR3^2nAXYpA*EK-dQmfjXS+T`FJ%~3SSV0GB>|;Vk~0MC<}aXrWXG=@e2I-~@*g;V|JLqhpp3aP!$|wea{70%?=o0iDoz8weHS-TxK+E-74m+9`y{c& zW((Q5rTqSNL9UTpBX-K=^Gc(GF5lynWKm8j0L{erCD^K>$lrp@o{;3FuxAriKXKu9 zFm0i+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Be~d}WM@>!Rp61j)a@jbj}m3`?9m{JuB0Qj@0sh32C* zY&0vL+-`Z!)(^0(KK&vh7D$?LM=E+d znQ2MnUKyk*H6(QzHH9Y{adT%l<(QnR?D|pO894S}Rm?OImr39L~%YLU33gPjXhE-L95_pwO(#vJW%=Ig0BJI0DshK|;*xt=UAvZ@0 zFDg%@k;4!z>o{)E-t%E>|7wNG%&@hUrS_XO|1_iJHM1p-4X`KIlrRucFF@xn&65Yc zVO^J?-67C=Qk)2%cyl<{k<|v1r#JB^ps4&3gdFxa zvyR6N9B~)Xw~I&n2<|i!E1@TKnDJ;q3ezwdiPU`I;g5P7;SEDE9EhTTudNrqUe>gR zR-hqP$v~V@xt57{s}pv5cUE&%JR2*+Q{EU9g>@@7 z-c*)l_ljf2`Pr!AX{T|*y}UfS|J{V|mPGHB&{gYK4b?D~zZ-cqxKmx6>l;3O=k8&b zE_3m%p?uRL$rPZ;tZ1)^!%jOzzL2|h>?N=paK37bN;k6VI*F83qON`Y+qLD0-Y{Un zUEJ7dRbb+M^(;XKy0%^DN3QEzAC09`%*`2Q@!XSFr4udIQitcx z)w*ce{TfvH_mgy!9qHa^fn^wnvD_|W&dRis=xco(9qEdO@V&f};gGAvkyLtDAgFKk-x*ckK`1l3ILvr|K)Et#1of@^-+YEn z=pIu|vW^ozR-f z8E7dsY&6}pp8Sd@z5j*2*%0pA3HI|)`lQ__ U0)<&p{~NPwsp+dWDBDE+A1pMp4gdfE diff --git a/src/LazyImage/tests/Kernel/AppKernelTrait.php b/src/LazyImage/tests/Kernel/AppKernelTrait.php deleted file mode 100644 index b5cc57be42a..00000000000 --- a/src/LazyImage/tests/Kernel/AppKernelTrait.php +++ /dev/null @@ -1,41 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\UX\LazyImage\Tests\Kernel; - -/** - * @author Titouan Galopin - * - * @internal - */ -trait AppKernelTrait -{ - public function getCacheDir(): string - { - return $this->createTmpDir('cache'); - } - - public function getLogDir(): string - { - return $this->createTmpDir('logs'); - } - - private function createTmpDir(string $type): string - { - $dir = sys_get_temp_dir().'/lazyimage_bundle/'.uniqid($type.'_', true); - - if (!file_exists($dir)) { - mkdir($dir, 0777, true); - } - - return $dir; - } -} diff --git a/src/LazyImage/tests/Kernel/EmptyAppKernel.php b/src/LazyImage/tests/Kernel/EmptyAppKernel.php deleted file mode 100644 index 03394163784..00000000000 --- a/src/LazyImage/tests/Kernel/EmptyAppKernel.php +++ /dev/null @@ -1,35 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\UX\LazyImage\Tests\Kernel; - -use Symfony\Component\Config\Loader\LoaderInterface; -use Symfony\Component\HttpKernel\Kernel; -use Symfony\UX\LazyImage\LazyImageBundle; - -/** - * @author Titouan Galopin - * - * @internal - */ -class EmptyAppKernel extends Kernel -{ - use AppKernelTrait; - - public function registerBundles(): iterable - { - return [new LazyImageBundle()]; - } - - public function registerContainerConfiguration(LoaderInterface $loader): void - { - } -} diff --git a/src/LazyImage/tests/Kernel/FrameworkAppKernel.php b/src/LazyImage/tests/Kernel/FrameworkAppKernel.php deleted file mode 100644 index dac1de8118f..00000000000 --- a/src/LazyImage/tests/Kernel/FrameworkAppKernel.php +++ /dev/null @@ -1,40 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\UX\LazyImage\Tests\Kernel; - -use Symfony\Bundle\FrameworkBundle\FrameworkBundle; -use Symfony\Component\Config\Loader\LoaderInterface; -use Symfony\Component\DependencyInjection\ContainerBuilder; -use Symfony\Component\HttpKernel\Kernel; -use Symfony\UX\LazyImage\LazyImageBundle; - -/** - * @author Titouan Galopin - * - * @internal - */ -class FrameworkAppKernel extends Kernel -{ - use AppKernelTrait; - - public function registerBundles(): iterable - { - return [new FrameworkBundle(), new LazyImageBundle()]; - } - - public function registerContainerConfiguration(LoaderInterface $loader): void - { - $loader->load(function (ContainerBuilder $container) { - $container->loadFromExtension('framework', ['secret' => '$ecret', 'test' => true]); - }); - } -} diff --git a/src/LazyImage/tests/Kernel/TwigAppKernel.php b/src/LazyImage/tests/Kernel/TwigAppKernel.php deleted file mode 100644 index 51869833765..00000000000 --- a/src/LazyImage/tests/Kernel/TwigAppKernel.php +++ /dev/null @@ -1,44 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\UX\LazyImage\Tests\Kernel; - -use Symfony\Bundle\FrameworkBundle\FrameworkBundle; -use Symfony\Bundle\TwigBundle\TwigBundle; -use Symfony\Component\Config\Loader\LoaderInterface; -use Symfony\Component\DependencyInjection\ContainerBuilder; -use Symfony\Component\HttpKernel\Kernel; -use Symfony\UX\LazyImage\LazyImageBundle; - -/** - * @author Titouan Galopin - * - * @internal - */ -class TwigAppKernel extends Kernel -{ - use AppKernelTrait; - - public function registerBundles(): iterable - { - return [new FrameworkBundle(), new TwigBundle(), new LazyImageBundle()]; - } - - public function registerContainerConfiguration(LoaderInterface $loader): void - { - $loader->load(function (ContainerBuilder $container) { - $container->loadFromExtension('framework', ['secret' => '$ecret', 'test' => true, 'http_method_override' => false]); - $container->loadFromExtension('twig', ['default_path' => __DIR__.'/templates', 'strict_variables' => true, 'exception_controller' => null]); - - $container->setAlias('test.lazy_image.blur_hash', 'lazy_image.blur_hash')->setPublic(true); - }); - } -} diff --git a/src/LazyImage/tests/LazyImageBundleTest.php b/src/LazyImage/tests/LazyImageBundleTest.php deleted file mode 100644 index ac553cedfd4..00000000000 --- a/src/LazyImage/tests/LazyImageBundleTest.php +++ /dev/null @@ -1,42 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\UX\LazyImage\Tests; - -use PHPUnit\Framework\TestCase; -use Symfony\Component\HttpKernel\Kernel; -use Symfony\UX\LazyImage\Tests\Kernel\EmptyAppKernel; -use Symfony\UX\LazyImage\Tests\Kernel\FrameworkAppKernel; -use Symfony\UX\LazyImage\Tests\Kernel\TwigAppKernel; - -/** - * @author Titouan Galopin - * - * @internal - */ -class LazyImageBundleTest extends TestCase -{ - public static function provideKernels() - { - yield 'empty' => [new EmptyAppKernel('test', true)]; - yield 'framework' => [new FrameworkAppKernel('test', true)]; - yield 'twig' => [new TwigAppKernel('test', true)]; - } - - /** - * @dataProvider provideKernels - */ - public function testBootKernel(Kernel $kernel) - { - $kernel->boot(); - $this->assertArrayHasKey('LazyImageBundle', $kernel->getBundles()); - } -} diff --git a/src/LazyImage/tests/baseline-ignore b/src/LazyImage/tests/baseline-ignore deleted file mode 100644 index 8661cedc451..00000000000 --- a/src/LazyImage/tests/baseline-ignore +++ /dev/null @@ -1 +0,0 @@ -%Since symfony/ux-lazy-image 2\.27\.0: The package is deprecated and will be removed in 3\.0\.% diff --git a/test_apps/encore-app/assets/controllers.json b/test_apps/encore-app/assets/controllers.json index f8a100fee0f..0775439e387 100644 --- a/test_apps/encore-app/assets/controllers.json +++ b/test_apps/encore-app/assets/controllers.json @@ -42,12 +42,6 @@ "fetch": "lazy" } }, - "@symfony/ux-lazy-image": { - "lazy-image": { - "enabled": true, - "fetch": "eager" - } - }, "@symfony/ux-leaflet-map": { "map": { "enabled": true, diff --git a/test_apps/encore-app/composer.json b/test_apps/encore-app/composer.json index 82bd0f9c761..e7983dfb810 100644 --- a/test_apps/encore-app/composer.json +++ b/test_apps/encore-app/composer.json @@ -19,7 +19,6 @@ "symfony/ux-dropzone": "^2.23", "symfony/ux-google-map": "^2.23", "symfony/ux-icons": "^2.23", - "symfony/ux-lazy-image": "^2.23", "symfony/ux-leaflet-map": "^2.23", "symfony/ux-live-component": "^2.23", "symfony/ux-map": "^2.23", diff --git a/test_apps/encore-app/config/bundles.php b/test_apps/encore-app/config/bundles.php index a71523ebb31..b59fe04beac 100644 --- a/test_apps/encore-app/config/bundles.php +++ b/test_apps/encore-app/config/bundles.php @@ -11,7 +11,6 @@ Symfony\UX\Map\UXMapBundle::class => ['all' => true], Symfony\Bundle\TwigBundle\TwigBundle::class => ['all' => true], Symfony\UX\Icons\UXIconsBundle::class => ['all' => true], - Symfony\UX\LazyImage\LazyImageBundle::class => ['all' => true], Symfony\UX\TwigComponent\TwigComponentBundle::class => ['all' => true], Symfony\UX\LiveComponent\LiveComponentBundle::class => ['all' => true], Symfony\Bundle\MercureBundle\MercureBundle::class => ['all' => true], diff --git a/test_apps/encore-app/config/packages/lazy_image.yaml b/test_apps/encore-app/config/packages/lazy_image.yaml deleted file mode 100644 index 0ea8aa9b6b4..00000000000 --- a/test_apps/encore-app/config/packages/lazy_image.yaml +++ /dev/null @@ -1,16 +0,0 @@ -# lazy_image: - # By default, images are fetched through "file_get_contents" function, but you can use your own implementation - # with an invokable service or a callable. - # https://symfony.com/bundles/ux-lazy-image/current/index.html#customizing-images-fetching - # fetch_image_content: 'App\BlurHash\FetchImageContent' - - # It is recommended to cache the generated BlurHash for performance reasons, to avoid generating it for each request. - # https://symfony.com/bundles/ux-lazy-image/current/index.html#performance-considerations - # cache: cache.lazy_image - -framework: - cache: - # pools: - # cache.lazy_image: - # If possible, prefer to use a cache adapter that is not cleared between deployments, like "cache.adapter.redis" - # adapter: cache.app diff --git a/test_apps/encore-app/package.json b/test_apps/encore-app/package.json index dad9d8cc00f..2b5df016125 100644 --- a/test_apps/encore-app/package.json +++ b/test_apps/encore-app/package.json @@ -12,7 +12,6 @@ "@symfony/ux-cropperjs": "file:vendor/symfony/ux-cropperjs/assets", "@symfony/ux-dropzone": "file:vendor/symfony/ux-dropzone/assets", "@symfony/ux-google-map": "file:vendor/symfony/ux-google-map/assets", - "@symfony/ux-lazy-image": "file:vendor/symfony/ux-lazy-image/assets", "@symfony/ux-leaflet-map": "file:vendor/symfony/ux-leaflet-map/assets", "@symfony/ux-live-component": "file:vendor/symfony/ux-live-component/assets", "@symfony/ux-notify": "file:vendor/symfony/ux-notify/assets", diff --git a/test_apps/encore-app/symfony.lock b/test_apps/encore-app/symfony.lock index ec3bc6f9cc3..5777c13c81c 100644 --- a/test_apps/encore-app/symfony.lock +++ b/test_apps/encore-app/symfony.lock @@ -184,18 +184,6 @@ "assets/icons/symfony.svg" ] }, - "symfony/ux-lazy-image": { - "version": "2.23", - "recipe": { - "repo": "github.com/symfony/recipes", - "branch": "main", - "version": "2.18", - "ref": "f6554b7efe60280645ac979c80700f66b8432131" - }, - "files": [ - "config/packages/lazy_image.yaml" - ] - }, "symfony/ux-leaflet-map": { "version": "2.23", "recipe": { diff --git a/ux.symfony.com/assets/controllers.json b/ux.symfony.com/assets/controllers.json index 1e301eabbcd..dbbf6d8bd05 100644 --- a/ux.symfony.com/assets/controllers.json +++ b/ux.symfony.com/assets/controllers.json @@ -36,12 +36,6 @@ } } }, - "@symfony/ux-lazy-image": { - "lazy-image": { - "enabled": true, - "fetch": "lazy" - } - }, "@symfony/ux-leaflet-map": { "map": { "enabled": true, diff --git a/ux.symfony.com/composer.json b/ux.symfony.com/composer.json index dda10666536..0e5dbf72d1d 100644 --- a/ux.symfony.com/composer.json +++ b/ux.symfony.com/composer.json @@ -37,7 +37,6 @@ "symfony/ux-cropperjs": "2.x-dev", "symfony/ux-dropzone": "2.x-dev", "symfony/ux-icons": "2.x-dev", - "symfony/ux-lazy-image": "2.x-dev", "symfony/ux-leaflet-map": "2.x-dev", "symfony/ux-live-component": "2.x-dev", "symfony/ux-map": "2.x-dev", diff --git a/ux.symfony.com/composer.lock b/ux.symfony.com/composer.lock index 418d80e29a8..635723da7f0 100644 --- a/ux.symfony.com/composer.lock +++ b/ux.symfony.com/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "6c79221d08e8c24c875bf442d76aac9a", + "content-hash": "4c9bd0c5310dbd85e389042d3ab65e44", "packages": [ { "name": "composer/semver", @@ -7671,86 +7671,6 @@ ], "time": "2024-12-04T11:34:13+00:00" }, - { - "name": "symfony/ux-lazy-image", - "version": "2.x-dev", - "source": { - "type": "git", - "url": "https://github.com/symfony/ux-lazy-image.git", - "reference": "7b9d9be000799cf02d1163128026e2053a39a734" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/ux-lazy-image/zipball/7b9d9be000799cf02d1163128026e2053a39a734", - "reference": "7b9d9be000799cf02d1163128026e2053a39a734", - "shasum": "" - }, - "require": { - "php": ">=8.1", - "symfony/config": "^5.4|^6.0|^7.0", - "symfony/dependency-injection": "^5.4|^6.0|^7.0", - "symfony/http-kernel": "^5.4|^6.0|^7.0" - }, - "require-dev": { - "intervention/image": "^2.5|^3.0", - "kornrunner/blurhash": "^1.1", - "symfony/cache-contracts": "^2.2", - "symfony/framework-bundle": "^5.4|^6.0|^7.0", - "symfony/phpunit-bridge": "^5.2|^6.0|^7.0", - "symfony/twig-bundle": "^5.4|^6.0|^7.0", - "symfony/var-dumper": "^5.4|^6.0|^7.0" - }, - "default-branch": true, - "type": "symfony-bundle", - "extra": { - "thanks": { - "url": "https://github.com/symfony/ux", - "name": "symfony/ux" - } - }, - "autoload": { - "psr-4": { - "Symfony\\UX\\LazyImage\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Titouan Galopin", - "email": "galopintitouan@gmail.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Lazy image loader and utilities for Symfony", - "homepage": "https://symfony.com", - "keywords": [ - "symfony-ux" - ], - "support": { - "source": "https://github.com/symfony/ux-lazy-image/tree/v2.22.1" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2024-12-05T14:25:02+00:00" - }, { "name": "symfony/ux-leaflet-map", "version": "2.x-dev", @@ -12744,7 +12664,6 @@ "symfony/ux-cropperjs": 20, "symfony/ux-dropzone": 20, "symfony/ux-icons": 20, - "symfony/ux-lazy-image": 20, "symfony/ux-leaflet-map": 20, "symfony/ux-live-component": 20, "symfony/ux-map": 20, diff --git a/ux.symfony.com/config/bundles.php b/ux.symfony.com/config/bundles.php index 8a9c0837f2a..08e457db97b 100644 --- a/ux.symfony.com/config/bundles.php +++ b/ux.symfony.com/config/bundles.php @@ -13,7 +13,6 @@ Symfony\UX\LiveComponent\LiveComponentBundle::class => ['all' => true], Symfony\UX\Chartjs\ChartjsBundle::class => ['all' => true], Symfony\UX\Cropperjs\CropperjsBundle::class => ['all' => true], - Symfony\UX\LazyImage\LazyImageBundle::class => ['all' => true], Symfony\UX\Dropzone\DropzoneBundle::class => ['all' => true], Doctrine\Bundle\DoctrineBundle\DoctrineBundle::class => ['all' => true], Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle::class => ['all' => true], diff --git a/ux.symfony.com/src/Controller/UxPackage/LazyImageController.php b/ux.symfony.com/src/Controller/UxPackage/LazyImageController.php index 5989564d732..748bc7c56cf 100644 --- a/ux.symfony.com/src/Controller/UxPackage/LazyImageController.php +++ b/ux.symfony.com/src/Controller/UxPackage/LazyImageController.php @@ -22,11 +22,9 @@ class LazyImageController extends AbstractController public function __invoke(UxPackageRepository $packageRepository): Response { $package = $packageRepository->find('lazy-image'); - $legosFilePath = $this->getParameter('kernel.project_dir').'/assets/images/legos.jpg'; return $this->render('ux_packages/lazy_image.html.twig', [ 'package' => $package, - 'legosFilePath' => $legosFilePath, ]); } } diff --git a/ux.symfony.com/src/Service/UxPackageRepository.php b/ux.symfony.com/src/Service/UxPackageRepository.php index 45fee897d65..0ef5d020737 100644 --- a/ux.symfony.com/src/Service/UxPackageRepository.php +++ b/ux.symfony.com/src/Service/UxPackageRepository.php @@ -187,6 +187,7 @@ public function findAll(?string $query = null, ?bool $deprecated = null): array 'linear-gradient(136deg, #AC2777 -8%, #F246AD 105%)', 'Delay Loading with Blurhash', 'Optimize Image Loading with BlurHash', + isDeprecated: true, ), new UxPackage( diff --git a/ux.symfony.com/symfony.lock b/ux.symfony.com/symfony.lock index f0c43313f0a..2452f2c8350 100644 --- a/ux.symfony.com/symfony.lock +++ b/ux.symfony.com/symfony.lock @@ -560,9 +560,6 @@ "assets/icons/symfony.svg" ] }, - "symfony/ux-lazy-image": { - "version": "v2.1.1" - }, "symfony/ux-leaflet-map": { "version": "2.19", "recipe": { diff --git a/ux.symfony.com/templates/ux_packages/lazy_image.html.twig b/ux.symfony.com/templates/ux_packages/lazy_image.html.twig index 36b74abe11b..ce129e72691 100644 --- a/ux.symfony.com/templates/ux_packages/lazy_image.html.twig +++ b/ux.symfony.com/templates/ux_packages/lazy_image.html.twig @@ -1,51 +1,58 @@ -{% extends 'ux_packages/package.html.twig' %} +{% extends 'base.html.twig' %} -{% block package_header %} - {% component PackageHeader with { - package: 'lazy-image', - eyebrowText: 'Images that Zoom', - } %} - {% block title_header %} - Load fast with Lazy Images - {% endblock %} +{% set meta = { + title: package.humanName ~ ' - Symfony UX 2', + description: package.description, + canonical: url(package.route), + social: { + title: package.tagline ~ ' - Symfony UX 2' ~ package.humanName|u.trimStart('UX '), + description: package.description|striptags, + image: { + url: absolute_url(asset(package.getSocialImage('1200x675'))), + type: 'image/png', + width: 1200, + height: 675, + alt: package.humanName ~ ' - Component Icon', + }, + } +} %} - {% block sub_content %} - Serve small or blurred - images first, then load the real thing after the page loads. - {% endblock %} - {% endcomponent %} +{% block main %} +
+
+

Deprecated Package

+

UX LazyImage 2.x

+

This component is deprecated and will not receive further updates.
+ Instead, use the modern techniques to improve image loading performance + natively supported by all major browsers.

+
+
{% endblock %} -{% block code_block_left %} - - -
-
- - Load a small (or blurred) image first -
-
- - The real (large) image is downloaded after page load -
-
-
-
-{% endblock %} - -{% block code_block_right %} - A blurhash image that is replaced by the real image on load +{% block stylesheets %} + {{ parent() }} + {% endblock %} diff --git a/ux.symfony.com/tests/baseline-ignore b/ux.symfony.com/tests/baseline-ignore index 59ebb3a8e3e..3321cdbc818 100644 --- a/ux.symfony.com/tests/baseline-ignore +++ b/ux.symfony.com/tests/baseline-ignore @@ -1,2 +1 @@ -%Since symfony/ux-lazy-image 2\.27\.0: The package is deprecated and will be removed in 3\.0\.% %Since symfony/ux-toggle-password 2\.29\.0: The package is deprecated and will be removed in 3\.0\.%