mardi 28 février 2017

How can a variable be used to set the src of an image in a production Ember app?

I have some images in my Ember app that are static files declared in ember-cli-build.js.

When the app is used in production, the URLs of the images will change from /icons/icon.png to something like /icons/icon-9ace8daf640d474c5472a54df98a4299.png. So this:

<img src="/icons/icon.png">

becomes:

<img src="/icons/icon-9ace8daf640d474c5472a54df98a4299.png">

How don't know why this happens (browser cache?). This breaks my images where the src comes from a variable. For example:

<img src="">

If imgURL equals /icons/icon.png, then the browser will be dealing with <img src="/icons/icon.png"> and the request will fail because the URL leads to nothing. In development everything works as expected.

How can a variable be used to set the src of an image in a production Ember app?




Aucun commentaire:

Enregistrer un commentaire