Paul-Riggott / PS-Scripts

Photoshop Scripts
195 stars 73 forks source link

Crash when using "KeyWordCount.jsx" in Bridge on folders #4

Closed rob-kne closed 6 years ago

rob-kne commented 6 years ago

This script works well and is really helpful, but it keeps crashing Adobe Bridge CC when I hover over a folder (not on purpose, sometimes my mouse just stays some seconds on the same place).

Error message is: "undefined is no abject".

Is there a way to tell the script to ignore folders, so it won't crash every time I hover over a folder?

Thanks a lot in advance.

rob-kne commented 6 years ago

has been fixed by another user here (line 3 is new and now ignores folders):

KeyWordCount = function(event){    
   if ((event.type == 'hover') && (event.object instanceof Thumbnail)) {  
       if(event.object.spec instanceof Folder) return;  
           var Thumb  = new Thumbnail(event.object.spec);  
            var md = Thumb.synchronousMetadata;  
                md.namespace = "http://ns.adobe.com/photoshop/1.0/";   
                if(md.Keywords.length >0){  
            Thumb.core.itemContent.tooltip = "Keyword Count = " +md.Keywords.length;     
            }  
      return { handled:false};  
  }  
}  
app.eventHandlers.push( { handler: KeyWordCount } );  
var prefs = app.preferences;  
try{  
if(!prefs.ShowTooltips) prefs.ShowTooltips=true;  
}catch(e){}