mardi 23 juin 2015

Add a function which returns a search and replace for an attribute

app/models/pictures.js

import DS from 'ember-data';

var Picture = DS.Model.extend({
  url: DS.attr('string')
});

export default Picture;

This is an example JSON data set:

{
 - pictures: [
    - {
        id: 1,
        url: "http://ift.tt/1Hbjvhm"
      }
   ]
}

I need to display a smaller version of a picture which is already stored on the server but has medium instead of large in the URL. How can I add a function to the picture model which returns a search and replace for s/large/medium/ of the url attribute?




Aucun commentaire:

Enregistrer un commentaire