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

Report missing images #872

Closed
michaelmcandrew opened this issue Mar 23, 2016 · 9 comments
Closed

Report missing images #872

michaelmcandrew opened this issue Mar 23, 2016 · 9 comments
Milestone

Comments

@michaelmcandrew
Copy link

Hello,
I'm thinking that it would be useful to report when local images that are referenced in the chapter are missing from the repo.

Wondering if this has been thought about before, and if there are any reasons why it isn't implemented (apart from resources/priorities).

I'd be willing to give it a go if people think it is a good idea.

@d0ugal
Copy link
Member

d0ugal commented Mar 23, 2016

Seems like a good idea to me. We already display warnings for broken links to '.md' files. Looking at how that works would probably be a good start.

@waylan
Copy link
Member

waylan commented Apr 1, 2016

This could be a little tricky as Markdown files are checked against the Nav (a previously compiled list of pages), not against the file system. And in that part of the code we don't have access to the doc_dir or the site_dir so we only have the relative path with no way to make it absolute and therefore no way to check it against the file system. For that matter, we don't even have access to the location of the current file, so there is no way to know what the path is relative to (i.e., ../../some/path/).

In the end, I expect this to be more difficult that one would think. This will likely also be a problem if/when support for "hidden" pages is added (see #699). Those pages will be explicitly absent from the Nav and should not generate a warning, but with no way to determine that within the Markdown Extension, there is no way to conditionally not raise the warning.

I see two possibilities to that problem (which would also directly affect this issue):

  1. Remove all related warnings about missing files, which would make any fix here moot.
  2. Refactor the relevant code to address all of the issues above, which would make both this and hidden files possible.

The problem stems in part from the fact that Python-Markdown does not really support passing data to an extension to modify its behavior on a file-by-file basis. The idea is that you create a Markdown instance with a config, and that instance is used (without changing behavior) for multiple files. Of course, MkDocs gets around this by creating a new instance for each page, but the API wasn't really designed with this use-case in mind.

@michaelmcandrew
Copy link
Author

Hey there,
Thanks for your pointers. It doesn't sound trivial but I'll take a look and let you know how I get on...

@waylan waylan added this to the Post 1.0 milestone Dec 2, 2016
@waylan waylan mentioned this issue Jun 8, 2018
@waylan waylan closed this as completed in 34ef3ca Jun 28, 2018
@zhangzq
Copy link

zhangzq commented Sep 4, 2018

How can I ignore this? I put the images somewhere not in the same repo, then got lots of warning.

@waylan
Copy link
Member

waylan commented Sep 4, 2018

@zhangzq warnings are only issued for relative paths. If your images are in a different repo, then they are not within the MkDocs site and should be absolute paths, which would avoid the warnings.

@zhangzq
Copy link

zhangzq commented Sep 4, 2018

@waylan thanks. I'll change them to absolute paths.

@zhangzq
Copy link

zhangzq commented Sep 5, 2018

@waylan I found the absolute paths must contains the whole domain part, i.e. http://domain.com/path/file.pdf

However, I used different domains in internal and public deploys.

Can I use [link](/path/file.pdf) for link without warning?

@waylan
Copy link
Member

waylan commented Sep 5, 2018

Can I use [link](/path/file.pdf) for link without warning?

Yes, that should work fine. If it does not, please open a new issue.

@zhangzq
Copy link

zhangzq commented Sep 5, 2018

@waylan I opened a new issue at #1621 .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants