Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Relative sources in <img> tags in README.md are not rewritten to absolute URLs #192

Closed
fabiospampinato opened this issue Jul 13, 2017 · 14 comments
Assignees
Labels
feature-request Request for new features or functionality help wanted Issues identified as good community contribution opportunities verified Verification succeeded
Milestone

Comments

@fabiospampinato
Copy link
Contributor

I wrote a readme file in markdown, and I had no problems putting a local gif in it, but vsce complained about a local png, maybe because I inserted it like this (just for centering it):

<p align="center">
	<img src="resources/logo.png" alt="Logo">
</p>
@joaomoreno
Copy link
Member

Can you show me what "complained" means? Did you get an error?

@fabiospampinato
Copy link
Contributor Author

Exactly, more specifically this error:

Error: Images in README.md must come from an HTTPS source: resources/logo.png

@joaomoreno
Copy link
Member

joaomoreno commented Jul 17, 2017

Is your extension in a GitHub repository? Can I check its sources?

@fabiospampinato
Copy link
Contributor Author

Sure, here it is.

@joaomoreno
Copy link
Member

I've cloned that repo and ran npm i and then vsce package. It worked:

vscode-projects-plus master* → vsce package
Executing prepublish script 'npm run vscode:prepublish'...

> vscode-projects-plus@1.0.1 vscode:prepublish /Users/joao/Desktop/vscode-projects-plus
> tsc -p ./

Created: /Users/joao/Desktop/vscode-projects-plus/vscode-projects-plus-1.0.1.vsix

Something must be off in your machine.

Do you have the latest vsce installed?

@joaomoreno joaomoreno self-assigned this Jul 17, 2017
@joaomoreno joaomoreno added this to the Backlog milestone Jul 17, 2017
@fabiospampinato
Copy link
Contributor Author

You forgot to edit the readme, it worked because now it's written in other way, otherwise I wouldn't be able to publish it because of the error I'm reporting.

Replace this:

<img src="https://raw.githubusercontent.com/fabiospampinato/vscode-projects-plus/master/resources/logo-128x128.png" alt="Logo">

With this:

<img src="resources/logo.png" alt="Logo">

If you have sed available just run:

sed -i -e 's/https:\/\/raw.githubusercontent.com\/fabiospampinato\/vscode-projects-plus\/master\/resources\/logo-128x128.png/resources\/logo.png/g' README.md

Yes, I'm using the latest version of vsce.

@fabiospampinato
Copy link
Contributor Author

fabiospampinato commented Jul 17, 2017

I believe I found the problem, here it checks if the url is relative, but just for images written in the markdown syntax.

If the image is written as an html tag it doesn't run the same check.

@joaomoreno
Copy link
Member

Got it. We don't support relative paths in <img> tags. You simply won't be able to reference that image in that relative fashion and keep using <img> tags.

Either keep using a full URL in the <img> tag, or drop the centered paragraph tag and use the markdown syntax for images: ![Logo](resources/logo-128x128.png)

@fabiospampinato
Copy link
Contributor Author

Is there a good reason for not enforcing the same rules for both cases?

@joaomoreno
Copy link
Member

We try to locate (regex) where images are used in Markdown and upon finding those locations we rewrite their relative URLs to be absolute ones, if we also detect the repository in which the extension will be hosted. We don't do the same for image tags since that is just harder to parse and rewrite. If you feel that passionate about it, feel free to submit a PR which addresses that. 👍

@joaomoreno joaomoreno reopened this Jul 19, 2017
@joaomoreno joaomoreno changed the title It may complain about images with local src Relative sources in <img> tags in README.md are not rewritten to absolute URLs Jul 19, 2017
@letmaik
Copy link
Member

letmaik commented Aug 2, 2017

I would find this very useful as well. I can't use the markdown syntax for images as I need to include the width attribute. The reason is simple: the image is a screenshot made on a high-dpi screen, and it just blows up in size as browsers don't read pixel density information (which PNGs don't have anyway) and just assume 72. Setting an explicit width fixes that on all display densities.

Demonstration:

Markdown syntax:
![](https://raw.githubusercontent.com/letmaik/vscode-git-tree-compare/master/screenshots/main.png)

HTML:
<img src="https://raw.githubusercontent.com/letmaik/vscode-git-tree-compare/master/screenshots/main.png" width="230">

letmaik added a commit to letmaik/vscode-git-tree-compare that referenced this issue Aug 2, 2017
JohannesHoppe added a commit to angular-schule/vscode-angular-schule-extension-pack that referenced this issue Oct 26, 2017
qinezh added a commit to qinezh/vscode-gitlink that referenced this issue Mar 25, 2018
gkalpak added a commit to gkalpak/aio-docs-utils that referenced this issue Aug 22, 2018
Using HTML for images (which allows centering and sizing) requires
absolute URLs for `vcse` to not complain (which ruins locality) :(

Related issue: microsoft/vscode-vsce#192
gkalpak added a commit to gkalpak/aio-docs-utils that referenced this issue Aug 23, 2018
Using HTML for images (which allows centering and sizing) requires
absolute URLs for `vcse` to not complain (which ruins locality) :(

Related issue: microsoft/vscode-vsce#192
@joaomoreno joaomoreno added feature-request Request for new features or functionality help wanted Issues identified as good community contribution opportunities labels Sep 20, 2018
@joaomoreno joaomoreno removed their assignment Sep 20, 2018
dlech added a commit to dlech/vscode-vsce that referenced this issue Mar 3, 2019
This adds a check for <img> tags in the readme file and modifies relative links just as it does for markdown images.

fixes microsoft#192
@chrisdothtml
Copy link

chrisdothtml commented Jun 3, 2019

+1

My use case is with aligning images. AFAICT there's no way to do it with markdown

EDIT: whoops, thought this was an issue for adding support on Github, not vscode 🤦‍♂

@joaomoreno joaomoreno removed this from the Backlog milestone Oct 11, 2019
dlech added a commit to dlech/vscode-vsce that referenced this issue Oct 28, 2019
This adds a check for <img> tags in the readme file and modifies relative links just as it does for markdown images.

fixes microsoft#192
@joaomoreno joaomoreno added this to the October 2019 milestone Oct 29, 2019
@joaomoreno joaomoreno added the verification-needed Verification of issue is requested label Oct 29, 2019
@JacksonKearl JacksonKearl added verified Verification succeeded and removed verification-needed Verification of issue is requested labels Oct 30, 2019
@Abbyyan
Copy link

Abbyyan commented Feb 14, 2020

But why even if i use a http url , it can't works.
![commands.gif](http://xxxxxx)
The Error is Images in README.md must come from an HTTPS source: http://xx

@letmaik
Copy link
Member

letmaik commented Feb 14, 2020

Switch to https ;-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request Request for new features or functionality help wanted Issues identified as good community contribution opportunities verified Verification succeeded
Projects
None yet
Development

No branches or pull requests

6 participants