2

I have the following issue with mithril

Image is display properly when it is a proper img tag

`<img src="images/erp/C:%5CProgram%20Files%20(x86)%5CMYTEST%5Cbitmaps%5C10001.jpg"  class="scale">`

But same image not rendered at all when it is set as background-image url

`background-image: url("images/erp/C:%5CProgram%20Files%20(x86)%5CMYTEST%5Cbitmaps%5C10001.jpg");`
Hiran
  • 698
  • 1
  • 10
  • 29
  • 1
    It looks like you're using a template literal to define a string representing a CSS property value map. How are you applying this in your Mithril code? – Barney Mar 23 '16 at 14:19
  • It look strange to have a "C:/Program Files" path in your image source path. Are you sure of your path? You should copy the image in a simpler path in the image/erp folder for example and try again to see if your css property is correctly interpreted. – fluminis Mar 30 '16 at 06:37

1 Answers1

1

Based on this issue the cause is a bug in the string C:\Tmp\a\field.png is converted into "C:Tmpa\f ield.png"

This javascript:

view: function (ctrl) {
 return [m("button", [m("img[src='C:\\Tmp\\a\\field.png\']"),"btn img"]),
  m("div", {'style': { 'background-image' : 'url(\"field.png\")'}},"div a"),
  m("div", {'style': { 'background-image' : 'url(\"C:\\Tmp\\a\\field.png\")'}},"div b")];
}

is rendered to this html

<button><img src="C:\Temp\mith\field.png">img inside a btn</button>
<div style="background-image: url("field.png");">no path</div>
<div style="background-image: url("C:Tmp\a\f ield.png");">with path</div>
surfmuggle
  • 5,527
  • 7
  • 48
  • 77