Brightspot CMS Developer Guide

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

import com.psddev.cms.image.ImageSize;
import com.psddev.cms.image.ImageSizeProvider;

public class StaticImageSizeProvider implements ImageSizeProvider { 

    public Set<ImageSize> getAll() { 
        return Stream.of(ImageSize.builder()
                       .displayName("Square large 50x50")
                       .displayName("Square huge 100x100")
                       .displayName("Square massive 150x150")
                       .displayName("Square gargantuan 200x200")

    public ImageSize get(List<String> list, String s) {
        return null;
  • Declares a concrete class that implements ImageSizeProvider. (If you are using themes, Brightspot automatically uses the class ThemeImageSizeProvider that also implements ImageSizeProvider to read image sizes from the theme’s configuration file _config.json.)
  • Implements the method getAll. You must implement this method for instances of ImageSize to 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.

import com.psddev.cms.image.ImageSizeProvider;
import com.psddev.dari.db.ApplicationFilter;
import com.psddev.dari.util.AbstractFilter;
import com.psddev.dari.util.ThreadLocalStack;

class StaticImageSizeProviderFilter extends AbstractFilter implements AbstractFilter.Auto {

    public void updateDependencies(Class<? extends AbstractFilter> filterClass, List<Class<? extends Filter>> dependencies) {
        if (ApplicationFilter.class.isAssignableFrom(filterClass)) {

    protected void doRequest(HttpServletRequest request, HttpServletResponse response, FilterChain chain) throws Exception {
        ThreadLocalStack<ImageSizeProvider> providerStack = ImageSizeProvider.getCurrentStack();
        providerStack.push(new StaticImageSizeProvider()); 

        try {
            chain.doFilter(request, response);

        } finally {
  • Pushes onto the ImageSizeProvider stack instances of StaticImageSizeProvider as described in the snippet "Implementing ImageSizeProvider." Generally, the class name in that line must be identical to the class name you used for implementing ImageSizeProvider.

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.)

Custom image sizes in sizes tab

See also:

Previous Topic
Creating image sizes
Next Topic
Retrieving image information
Was this topic helpful?
Thanks for your feedback.
The elements that get you up and running in a matter of days, from pre-built content types, to modules, to landing pages.

Content types
Landing pages
Everything you need to manage and administer content within Brightspot CMS, including plug-and-play integrations.

Authoring content
Admin configurations
A guide for installing, supporting and administering code on the Brightspot platform, including integrations requiring developer support to use.

Field types
Content modeling
Rich-text elements