ampproject / ampproject/eleventy-plugin-amp

Could not optimize image (TypeError: Only absolute URLs are supported)

Open
#108 0 comments 0 reactions 0 assignees View on GitHub
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

Open the contributing 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.