lundi 3 août 2015

Ember cli replace image standard if image model is null in json

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: http://ift.tt/1IBzkbQ to http://ift.tt/1GPlWQd) 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('http://ift.tt/1SE2dij');
        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 (http://ift.tt/1GPlWQd) really exists.

What am i doing wrong?

See the printscreen

enter image description here




Aucun commentaire:

Enregistrer un commentaire