Just to save you the time... on('ready',function(){
"use strict";
var getCleanImgsrc = function (imgsrc) {
var parts = imgsrc.match(/(.*\/images\/.*)(thumb|med|original|max)(.*)$/);
if(parts) {
return parts[1]+'thumb'+parts[3];
}
return;
};
on('chat:message',function(msg){
var t,img;
if('api' === msg.type && playerIsGM(msg.playerid) && msg.content.match(/^!default-avatar/) ){
if(msg.selected){
if(1 !== msg.selected.length){
sendChat('default-avatar','/w gm Please select only one graphic.');
} else {
t=getObj('graphic', msg.selected[0]._id);
if(t){
img=getCleanImgsrc(t.get('imgsrc'));
if(img){
_.chain(filterObjs(function(o){
return o.get('type') === 'character' &&
o.get('avatar') === '';
}))
.each(function(o,k,a){
o.set({
avatar: img
});
});
} else {
sendChat('default-avatar','/w gm Can only use a graphic that is in a user library. The selected graphic is in the Marketplace. Please choose one from your library or download this one from the Marketplace and upload it to your library.');
}
} else {
sendChat('default-avatar','/w gm Please select a graphic.');
}
}
}
}
});
});
Drag an image to your VTT (needs to be in your Library, not the Marketplace, so download/upload as needed), then select it and run this: !default-avatar It will find every character that doesn't have an avatar and set the img you selected as the avatar.