Switching background images with javascript forces absolute path -



Switching background images with javascript forces absolute path -

i have div begins follows:

<div id="info_picture" style="background-image: url('assets/img/channels/banners/3')"></div>

the reason there's no file extension image can uploaded user, , don't want store extension in database (or forcefulness them utilize 1 image format). have line of javascript changes background image:

info_picture.style.backgroundimage = "url('assets/img/channels/banners/"+channel+"')";

however, on inspecting element, background image style appears absolute path, rather relative path specified in script. that's problem, because without extension, causes transferred application/octet-stream. chrome chucks warning, , image doesn't display. how can forcefulness load relative path instead of absolute path?

my gut says it's not javascript problem or browser issue.

the problem may in actual file, , file has application/octet-stream mime type.

if you,

i wouldn't utilize assets directory serve image. selection public/images directory @ least. assets not dynamic files, static files.

if image served server without extension name, serve images application setting mime types through controller, guessing utilize rails.

javascript background-image

Comments

Popular posts from this blog

web services - java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer -

Accessing MATLAB's unicode strings from C -

javascript - mongodb won't find my schema method in nested container -