`enhanced:img` returns `NaN` height when image is imported within script block
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 20.8k
- Forks
- 2.3k
- Avg merge
- 1d 16h
- Merged PRs (30d)
- 156
Description
Describe the bug
This HTML was generated by enhanced:img with the same source image, but loaded two different ways:
Notice one has a valid height and the second is NaN.
Reproduction
The first (green box) containing the valid height was generated using:
<enhanced:img src="$lib/assets/images/example.png?w=280;560" alt="" width="280"/>
The second (red box) was generated using:
<script lang="ts">
import example from "$lib/assets/images/example.png?enhanced&w=280;560"
</script>
<enhanced:img src={example} alt="" width="280" />
I assume this is unexpected b/c the property would at least be omitted but never added as NaN.
Logs
No response
System Info
System:
OS: macOS 14.5
npmPackages:
@sveltejs/adapter-cloudflare: ^4.7.2 => 4.7.2
@sveltejs/enhanced-img: ^0.3.8 => 0.3.8
@sveltejs/kit: ^2.5.28 => 2.5.28
@sveltejs/vite-plugin-svelte: ^4.0.0-next.7 => 4.0.0-next.7
svelte: ^5.0.0-next.257 => 5.0.0-next.257
vite: ^5.4.8 => 5.4.8
Severity
annoyance
Additional Information
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the issue with the two Svelte snippets in the report, comparing the generated image markup for the direct enhanced:img source and the imported ?enhanced source. Done means the imported-image path no longer produces a height of NaN; the report does not name a source file or test to run.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, typescript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100