• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

tito10047 / progressive-image-bundle / 20616398077

31 Dec 2025 09:41AM UTC coverage: 91.703% (-1.4%) from 93.112%
20616398077

push

github

tito10047
add preload support with `srcSet` and `sizes`: update `PreloadCollector` and `KernelResponseEventListener` to handle image-specific attributes; extend `Image` component to pass raw attributes; improve tests to validate preload headers and responsive image strategies; update dependencies

34 of 45 new or added lines in 3 files covered. (75.56%)

420 of 458 relevant lines covered (91.7%)

70.73 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

55.0
/src/Service/PreloadCollector.php
1
<?php
2

3
namespace Tito10047\ProgressiveImageBundle\Service;
4

5
use Symfony\Component\HttpFoundation\RequestStack;
6
use Symfony\Component\WebLink\GenericLinkProvider;
7
use Symfony\Component\WebLink\Link;
8

9
class PreloadCollector {
10
        private array $urls = [];
11

12
        public function __construct(
13
                private readonly RequestStack $requestStack
14
        ) {
15
        }
76✔
16

17
        public function add(string $url, string $as = 'image', string $priority = 'high', ?string $srcset = null, ?string $sizes = null): void {
18
                $this->urls[$url] = [
16✔
19
                        'as' => $as,
16✔
20
                        'priority' => $priority,
16✔
21
                        'imagesrcset' => $srcset,
16✔
22
                        'imagesizes' => $sizes,
16✔
23
                ];
16✔
24

25
                $request = $this->requestStack->getCurrentRequest();
16✔
26
                if (!$request) {
16✔
27
                        return;
16✔
28
                }
29

NEW
30
                $link = (new Link('preload', $url))
×
NEW
31
                        ->withAttribute('as', $as)
×
NEW
32
                        ->withAttribute('fetchpriority', $priority);
×
33

NEW
34
                if ($srcset) {
×
NEW
35
                        $link = $link->withAttribute('imagesrcset', $srcset);
×
36
                }
37

NEW
38
                if ($sizes) {
×
NEW
39
                        $link = $link->withAttribute('imagesizes', $sizes);
×
40
                }
41

NEW
42
                $linkProvider = $request->attributes->get('_links', new GenericLinkProvider());
×
NEW
43
                $request->attributes->set('_links', $linkProvider->withLink($link));
×
44
        }
45

46
        public function getUrls(): array {
47
                return $this->urls;
16✔
48
        }
49
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc