ampproject / ampproject/eleventy-plugin-amp
Could not optimize image (TypeError: Only absolute URLs are supported)
- Dominant language
- JavaScript
- Stars
- 51
- Forks
- 27
- PR merge metrics
- No merged PRs in 30d
Description
Hi,
I have some errors when trying to use image optimization, even I have already created process.env.
Image optimization always using my local path.
### This is my plugin settings.
```
eleventyConfig.addPlugin(ampPlugin, {
ampRuntimeHost:
process.env.ENV === 'prod' ? 'https://mydomain.com' : 'http://localhost:8080',
imageOptimization: true,
validation: false,
});
```
The error :
```
AMP Img Optimization WARNING Could not optimize image ({{ my local path }}\assets\{{ myfilename }}.png, 820w): TypeError: Only absolute URLs are supported
```
Is any wrong with the setup?
Thank you
Contributor guide
Research direction
Start by reproducing the image optimization warning with the plugin settings shown, including the process.env.ENV-dependent ampRuntimeHost and imageOptimization option. Trace how the local image path is passed to optimization and confirm done when the configured host produces a valid absolute image URL and optimization completes without the TypeError.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- web-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100