tea3 / hexo-generator-amp

AMP ⚡ HTML (Accelerated Mobile Pages) generator for Hexo.
MIT License
127 stars 28 forks source link

Local images not found. #31

Closed jamiei closed 7 years ago

jamiei commented 7 years ago

None of my local images are linked from the generated content and an error is emitted during generation: "This plugin can not acquire the width and height of such url images. Please change the URL to HTTP or HTTPS, or add height and width."

I think I might be misunderstanding how this code works, but I was looking at this line here: https://github.com/tea3/hexo-generator-amp/blob/ef879d27b701d9e29ea4cbe1ed288f5a15804f4f/lib/imageSize.js#L27 Does this mean that a local image file specified in a markdown template like this: ![Image description](localimage.jpg) Will be attempted to be found by the plugin under the path $pwd|$cwd + 'source/' + 'localimage.jpg'?

If so, would that explain why none of my images are replaced with amp equivalents?

tea3 commented 7 years ago

@jamiei Plugin will found the path $pwd|$cwd + 'source/' + 'localimage.jpg' as you would guess.

You are not using post_asset_folder ? https://hexo.io/docs/asset-folders.html

jamiei commented 7 years ago

@tea3 - I am, but wouldn't this mean that the image is actually be in $pwd|$cwd + 'source/' + '_draft/'|'_posts' + $postname + 'localimage.jpg'?

Also meant to say, thanks for the awesome work. Aside from this issue, I was able to generate an amp site with almost no effort.

tea3 commented 7 years ago

@jamiei You're welcome. I assume various image paths, but unfortunately plugin not support it yet. I want to support that file path.

tea3 commented 7 years ago

@jamiei Fixed image path . please reinstall latest version and check that issue solved.

$ npm uninstall hexo-generator-amp --save
$ npm install git+https://github.com/tea3/hexo-generator-amp.git --save
$ hexo clean
$ hexo s

Please close this issue once it is resolved.

jamiei commented 7 years ago

I can confirm this is resolved for me, thank-you so much for the rapid response. I got half-way through a fix for myself, but hadn't quite got my head around it!