Commit ff7b10d
fix(clone): drop <picture> <source> elements so inlined <img> src is not overridden
A <picture>'s <source> out-ranks its <img>'s own src. The sources were cloned
verbatim, so the exported SVG re-selected an external URL at rasterization time —
and svg-as-image may not load external resources. The photo never painted, however
correctly the <img> had been inlined, producing a large SVG that rasterized to a
small blank PNG.
Skip <source> children of a <picture> when cloning. The <img> clone is already
frozen to the variant the live page chose (freezeImgSrcset sets src =
original.currentSrc and strips srcset/sizes), so the sources carry nothing still
needed and art direction is preserved.
Verified against a WordPress hero carousel whose slides use <picture> with a
catch-all <source media="(min-width: 0px)">, which made the failure deterministic.
With the site's real assets and an identical 723 KB SVG: 48 KB PNG with 0% of the
photo painted before, 2046 KB and 100% after. Capturing at a 1600px viewport embeds
the 2200x1200 crops; at 500px it embeds the 600x1000 crops.
Closes #462
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>1 parent 509bed1 commit ff7b10d
2 files changed
Lines changed: 53 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
109 | 109 | | |
110 | 110 | | |
111 | 111 | | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
112 | 157 | | |
113 | 158 | | |
114 | 159 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
186 | 186 | | |
187 | 187 | | |
188 | 188 | | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
189 | 197 | | |
190 | 198 | | |
191 | 199 | | |
| |||
0 commit comments