0

Consider the following code:

if (realNodeType === 'custom') {
    let icon = '/icon/custom/' + item.get('icon') + '.png';
    let iconUrl = window.location.protocol + '//' + window.location.host + '/' + window.location.pathname.split('/')[1] + icon;
    treeNodeMap[parentLabel].get('nodes').add(new Backbone.Model({
        id: item.get('id'),
        name: item.get('name'),
        icon: iconUrl
    }));
}

icon returns the url of the image I'm looking for. The only problem is that I'm getting it in a slightly bigger dimension (21x21). What I would like to do is to resize it once I get it to (16x16). Is this possible?

I thought about adding another field success like this:

    ...
    id: item.get('id'),
    name: item.get('name'),
    icon: iconUrl,
    success: function(icon){
    //resizing goes here
    }

However, I'm unable to access the image's height and width using that method.

Jesse James
  • 1,203
  • 5
  • 22
  • 39

0 Answers0