Script - display images and icons

Confluence images and icons

This example shows listing all images and icons from the Confluence install.

{beanshell:output=wiki}
  String baseDir  = "<my confluence install dir>/confluence";     // web server base directory
  String imageDir = "/images/icons";            // sub path to images
  String path     = baseDir + imageDir;         // directory path on server 
  String server   = "http://<confluence url>";  // server url 
  String header   = "|| Icon || Icon name ||";  // wiki notation for 2 column table
  int numberOfColumns = 4;                      // adjust for appearance
  File icons = new File(path);                  
  String[] iconList = icons.list();             // all files in directory
  if (iconList == null) {
      out.println("List is empty");
  } else {
      Arrays.sort(iconList);                    // sort alphabetically
      int index = 0;                            // to list of icons
      int iconCount = iconList.length;  
      int numberPerColumn = (iconCount + numberOfColumns - 1)/numberOfColumns; // rounded appropriately
      out.println("{section}{column}");
      for (int column=1; column<=numberOfColumns; column++) {
          out.println(header);
          for (int i=0; (i < numberPerColumn) && (index < iconCount); i++) {       
              out.println("| !" + server + imageDir + "/" + iconList[index] + "! |" + iconList[index] + " | ");
              index++;
          }
          out.println("{column}{column}");
      }
      out.println("{column}{section}");
  }
  out.println("List for: " + icons);  // document where the list comes from
{beanshell}

Log a request with our support team.

Confluence®, Jira®, Atlassian Bamboo®, Bitbucket®, Fisheye®, and Atlassian Crucible® are registered trademarks of Atlassian®
Copyright © 2005 - 2024 Appfire | All rights reserved. Appfire™, the 'Apps for makers™' slogan and Bob Swift Atlassian Apps™ are all trademarks of Appfire Technologies, LLC.