Registering image sizes
The easiest way to configure the listing of image sizes in the image editor’s Sizes tab is through a theme’s configuration file _config.json. However, if you create image sizes using the class ImageSize, you can register them for display in the Sizes tab of the image editor by following the steps in this section.
Step 1: Implement ImageSizeProvider
1import com.psddev.cms.image.ImageSize;2import com.psddev.cms.image.ImageSizeProvider;34public class StaticImageSizeProvider implements ImageSizeProvider {56@Override7public Set<ImageSize> getAll() {8return Stream.of(ImageSize.builder()9.displayName("Square large 50x50")10.internalName("square-large")11.width(50)12.height(50)13.build(),14ImageSize.builder()15.displayName("Square huge 100x100")16.internalName("square-huge")17.width(100)18.height(100)19.build(),20ImageSize.builder()21.displayName("Square massive 150x150")22.internalName("square-massive")23.width(150)24.height(150)25.build(),26ImageSize.builder()27.displayName("Square gargantuan 200x200")28.internalName("square-gargantuan")29.width(200)30.height(200)31.build())32.collect(Collectors.toCollection(HashSet::new));33}3435@Override36public ImageSize get(List<String> list, String s) {37return null;38}39}
- 4. Declares a concrete class that implements ImageSizeProvider. (If you are using themes, Brightspot automatically uses the class
ThemeImageSizeProviderthat also implementsImageSizeProviderto read image sizes from the theme’s configuration file_config.json.) - 7. Implements the method
getAll. You must implement this method for instances ofImageSizeto appear in the image editor. The method in this snippet instantiates and returns custom image sizes with a display name, internal name, width, and height.
Step 2: Add set of images to ImageSizeProvider stack
Compose a class that extends AbstractFilter and implements AbstractFilter.Auto. Generally, at run time such classes place objects in various parts of the Brightspot UI.
1import com.psddev.cms.image.ImageSizeProvider;2import com.psddev.dari.db.ApplicationFilter;3import com.psddev.dari.util.AbstractFilter;4import com.psddev.dari.util.ThreadLocalStack;56class StaticImageSizeProviderFilter extends AbstractFilter implements AbstractFilter.Auto {78@Override9public void updateDependencies(Class<? extends AbstractFilter> filterClass, List<Class<? extends Filter>> dependencies) {10if (ApplicationFilter.class.isAssignableFrom(filterClass)) {11dependencies.add(getClass());12}13}1415@Override16protected void doRequest(HttpServletRequest request, HttpServletResponse response, FilterChain chain) throws Exception {17ThreadLocalStack<ImageSizeProvider> providerStack = ImageSizeProvider.getCurrentStack();18providerStack.push(new StaticImageSizeProvider());1920try {21chain.doFilter(request, response);2223} finally {24providerStack.pop();25}26}27}
- 18. Pushes onto the
ImageSizeProviderstack instances ofStaticImageSizeProvideras described in the snippet "Implementing ImageSizeProvider." Generally, the class name in that line must be identical to the class name you used for implementingImageSizeProvider.
Step 3: Reload Brightspot in browser
Brightspot automatically deploys the custom image sizes, and users see them in the image editor’s Sizes tab after reloading Brightspot in the browser. If the custom image sizes are not visible, restart the Brightspot server. (If the custom image sizes are still not visible, ensure Dari’s reloader is running; for details, see Reloader.)

See also: