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

tito10047 / progressive-image-bundle / 20617690786

31 Dec 2025 11:04AM UTC coverage: 91.757% (+0.05%) from 91.703%
20617690786

push

github

tito10047
add `original` breakpoint support: update `LiipImagineSrcsetGenerator`, `Image` component, and tests to handle `original` width and improve `srcset` generation

4 of 4 new or added lines in 2 files covered. (100.0%)

41 existing lines in 3 files now uncovered.

423 of 461 relevant lines covered (91.76%)

129.46 hits per line

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

100.0
/src/Event/KernelResponseEventListener.php
1
<?php
2

3
namespace Tito10047\ProgressiveImageBundle\Event;
4

5
use Tito10047\ProgressiveImageBundle\Service\PreloadCollector;
6
use Symfony\Component\HttpKernel\Event\ResponseEvent;
7

8
class KernelResponseEventListener {
9

10
        public function __construct(
11
                private readonly PreloadCollector $preloadCollector,
12
        ) { }
73✔
13

14
        public function __invoke(ResponseEvent $event) {
15
                $response = $event->getResponse();
73✔
16

17
                $preloads = $this->preloadCollector->getUrls();
73✔
18
                if (empty($preloads)) return;
73✔
19

20
                $links = [];
58✔
21
                foreach ($preloads as $url => $attr) {
58✔
22
                        $link = sprintf('<%s>; rel=preload; as=%s; fetchpriority=%s',
58✔
23
                                $url, $attr['as'], $attr['priority']);
58✔
24
                        if (!empty($attr['imagesrcset'])) {
58✔
UNCOV
25
                                $link .= sprintf('; imagesrcset="%s"', $attr['imagesrcset']);
14✔
26
                        }
27
                        if (!empty($attr['imagesizes'])) {
58✔
UNCOV
28
                                $link .= sprintf('; imagesizes="%s"', $attr['imagesizes']);
28✔
29
                        }
30
                        $links[] = $link;
58✔
31
                }
32
                $response->headers->set('Link', implode(', ', $links), false);
58✔
33

34
                $content = $response->getContent();
58✔
35

36
                $html = "";
58✔
37
                foreach ($preloads as $url => $attr) {
58✔
38
                        $html .= sprintf('<link rel="preload" href="%s" as="%s" fetchpriority="%s"',
58✔
39
                                $url, $attr['as'], $attr['priority']);
58✔
40
                        if (!empty($attr['imagesrcset'])) {
58✔
UNCOV
41
                                $html .= sprintf(' imagesrcset="%s"', $attr['imagesrcset']);
14✔
42
                        }
43
                        if (!empty($attr['imagesizes'])) {
58✔
UNCOV
44
                                $html .= sprintf(' imagesizes="%s"', $attr['imagesizes']);
28✔
45
                        }
46
                        $html .= '>';
58✔
47
                }
48

49
                $newContent = str_replace('</head>', $html . '</head>', $content);
58✔
50
                $response->setContent($newContent);
58✔
51
        }
52

53
}
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

© 2025 Coveralls, Inc