1

I'd like to use the internal shr "package" of emacs to display local images. The thing is that I can display online images but not local ones, that's quite strange isn't it!

Reproduce: Put in a random buffer this file:

<head><meta charset="UTF-8"></head>
<html>
  <head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8">
  </head>
  <body>
    <p>Extern file:<br/>
      <img src="http://www.thehindu.com/news/national/karnataka/article19571557.ece/alternates/FREE_300/28BGMYSMONKEY" alt="Extern file"/>
    </p>
    <p>Intern file:<br/>
      <img src="/tmp/monk/Trois-singes-644x427.jpg" alt="No local"/>
    </p>
  </body>
</html>

And call M-x shr-render-buffer. The online image is displayed, not the local one... enter image description here

-- EDIT -- After the proposition of the comment, I upload the full html I'm using, as well as a screenshot. I'm also using GNU Emacs 25.2.2 (x86_64-pc-linux-gnu, GTK+ Version 3.22.30).

enter image description here

<head><meta charset="UTF-8"></head>
<html>
  <head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8">
  </head>
  <body>
    <p>Extern file:<br/>
      <img src="http://www.thehindu.com/news/national/karnataka/article19571557.ece/alternates/FREE_300/28BGMYSMONKEY" alt="Extern file"/>
    </p>
    <p>Intern file:<br/>
      <img src="file:///tmp/monk/Trois-singes-644x427.jpg" alt="No local"/>
    </p>
  </body>
</html>

-- EDIT 2 -- I have no idea why, but I tried to restart emacs and try again (same code with file:///tmp/... for sure because it was saved in a file), and now it works perfectly... I've no idea what happened, I need to investigate. Thank you!

  • 1
    Try prepending file:// to the local file name, – Basil May 31 '18 at 1:51
  • @Basil It's not working either – tobiasBora May 31 '18 at 12:34
  • Works for me on Emacs versions 24-27. Are you sure you are writing file:///tmp/... and not file://tmp/...? Can you please update your question with the precise new HTML you are trying to render? What is your emacs-version? Does it work if you start Emacs with the -Q flag? – Basil May 31 '18 at 12:37
  • @Basil Very strange: since the beginning I was using file:///tmp/... and it was not working. So I tried -Q, it worked! Then I restarted emacs normally, and tried again... And it worked! No idea what appened, if this appends again I'll be back here. Meanwhile, thank you very much! – tobiasBora May 31 '18 at 23:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.