question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot display local image file using background-image CSS property

See original GitHub issue

I can’t seem to be able to read an image file from disk and set it as CSS background-image. The file correctly loads into the src attribute of an <img> tag and shows correct path in the inspector as:

C:\Users\Alex\Desktop\~tmpPreview\frame-9.png

but when it loads as CSS background-image, the path appears to be mangled like,

file:///C:/Userslex%C3%9Esktop~tmpPreview%0Frame-9.png

and the image never loads. console.log() shows the correct path.

Is this a bug or something I am unaware of?

Using: node-webkit-v0.10.0-rc2 / Windows 7 64-bit

<bountysource-plugin>

Want to back this issue? Post a bounty on it! We accept bounties via Bountysource. </bountysource-plugin>

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
Mithgolcommented, Jul 21, 2014

Try this:

$('.preview').css({
   'background-image': 'url(file:////' +
      imageSet[MYIMAGENUMGOESHERE].replace(/\\/g, '/') +
   ')'
});
0reactions
nwjs-botcommented, Aug 24, 2016

This should be working with latest version now.

In 0.13 we changed to an optimized architecture so more features can be supported, see http://nwjs.io/blog/whats-new-in-0.13/ and it’s good for keeping up with Chromium upstream – we released with Node.js v6.0 and new Chromium versions within 1 day after upstream release.

The new version would fixed many issues reported here and we’re scrubbing them. This issue is closed as we believe it should be fixed. Please leave a message if it isn’t and we’ll reopen it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to fix CSS background-image not working | HTML/CSS
1. Check that your CSS file is linked correctly in your HTML file. · 2. Make sure the image path is set correctly...
Read more >
html - CSS Background Image Not Displaying - Stack Overflow
According to your CSS file path, I will suppose it is at the same directory with your HTML page, you have to change...
Read more >
Forums - CSS - [Solved] Background Image Not Showing
1) The file name is EXACTLY right. 2) The file path is EXACTLY right. This file path presupposes that the image folder is...
Read more >
background-image - CSS: Cascading Style Sheets | MDN
The background-image CSS property sets one or more background images on an element.
Read more >
Fix CSS background image url not displaying ... - YouTube
Fix CSS background image url not displaying showing working in HTML CSS | Problem Solved Show SupportBuy Me a COFFEE: ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found