0

I want to display a standard image if the model in my json is null.

This is my function where first i successfully achieve to format the url in order to make it bigger (eg: https://i1.sndcdn.com/artworks-000121961221-bzjnxn-large.jpg to https://i1.sndcdn.com/artworks-000121961221-bzjnxn-t500x500.jpg) but then i can not assign a standard image when the model (artwork_url) is null.

formattedArtwork: Ember.computed('artwork_url', function() {
    var splitURL, url;
    if (this.get('artwork_url')) {
        url = this.get('artwork_url');
        splitURL = url.split('-large');
        return splitURL[0] + '-t500x500' + splitURL[1];
    } else {
        url = this.get('https://mystandardimage.jpg');
        return url;
    }
}),

So if it gets the arwork_url i can format and display the img but if it does not get i would like to put a general image url i created, at the moment it says that my url is undefined although that url (https://i1.sndcdn.com/artworks-000121961221-bzjnxn-t500x500.jpg) really exists.

What am i doing wrong?

See the printscreen

enter image description here

Koala7
  • 1,340
  • 7
  • 41
  • 83
  • Does your model have a `https://i1.sndcdn.com/artworks-000121961221-bzjnxn-t500x500.jpg` property? (it seems not, for `url` is undefined in your debugging session). Otherwise just `return "https://i1.sndcdn.com/artworks-000121961221-bzjnxn-t500x500.jpg"` – Frank Treacy Aug 03 '15 at 21:57
  • not it does not, put your answer – Koala7 Aug 03 '15 at 21:58

1 Answers1

1

After the debugger line, you should just return "https://i1.sndcdn.com/artworks-000121961221-bzjnxn-t500x500.jpg"

Frank Treacy
  • 3,386
  • 1
  • 16
  • 16