JAlbum/Views/Custom view codes

Revision as of 23 October 2025 23:02 by RobM (Comments | Contribs)

This is a list of third party supplied custom view codes. Just copy the code and paste it in to the code area of the custom view.

Area tagged by name

By RobM.

Replace the text 'Replace with the name to search for' with the name of the tagged region/area you want to search for. Note for the code to work all single and double quotes used in the 'Name' field must be removed, so don't include them in your search string.

If you want to have a view that shows all area tags by name replace the line 'if(faceLink.equals(name))' with 'if(!faceLink.equals(""))' It then doesn't matter what you enter in the text for 'Replace with the name to search for'.

Whilst the results will always be valid it is up to the skin being used as to whether or not regions/area tags are shown.

def checkLink(text) {
	text = text.replaceAll("'","");
	text = text.replaceAll("\"","");
	return text;
}

def getRegion(String name) {
if(obj.category == Category.image) {
  xmp = obj.vars.xmp;
  if(xmp != void && xmp != null) {
    try {	
      for (int i=1; (face = xmp.get("mwg-rs:Regions/mwg-rs:RegionList["+ i +"]/mwg-rs:Type")) != null; i++) {
        face = xmp.get("mwg-rs:Regions/mwg-rs:RegionList["+ i +"]/mwg-rs:Name");
	    if(face != null && xmp.get("mwg-rs:Regions/mwg-rs:RegionList["+ i +"]/mwg-rs:Description") != null) {
	      rDesc = xmp.get("mwg-rs:Regions/mwg-rs:RegionList["+ i +"]/mwg-rs:Description");
	      faceLink = checkLink(face);
	      rDescLink = checkLink(rDesc);
	      if(faceLink.equals(name)) 
	        return true
	      }
        }
      }
      catch(Exception e) {
        System.out.println(e);
      }
    }
  }
}

result = getRegion("Replace with the name to search for");

Rating

By RobM.

Show objects with a rating of 4 stars or more

obj.rating >= 4