Ember retrieve image through didInsertElement


#1

Hi, I have an Ember application that use select2. I have to punt inside the select2 the flags associated with the nation but when I upload the dist folder on apache the image is stored like

Language1-4caa60355ba79094264c91e5c3c921fa.png

so in my didInsertElement

'<span><img src="assets/flag/' + state.id + '.png" class="img-flag" /> ' + state.text + '</span>'

where state.id is Language1 but when I make the build… ember add to image 4caa60355ba79094264c91e5c3c921fa.png. So who can I retrieve the image?

Thanks in advance.


#2

Checkout https://github.com/rickharrison/broccoli-asset-rev . This is what’s actually doing the fingerprinting. It does optionally dump out a JSON file of all the fingerprinted files, you could use that to determine your path.

The other option is if you use literals, the broccoli-asset-rev addon will actually replace them in JS. So if that was: <img src="assets/flag/Language1.png" class="img-flag" /> it would actually be replaced. I’m guessing the state.id is dynamic, but perhaps you could create a map:

const ASSET_FILE_PATHS = {
  'Language1': '/Language1.png'
};
`<img src="assets/flag/${ASSET_FILE_PATHS[state.id]}" class="img-flag" />`

`