

Create the Responsive Image Style in Drupal I’m going to add the following new image styles to the list:Ĥ. To create an image style in Drupal, Visit the Image styles page via the Manage administrative menu, navigate to Configuration > Media > Image styles (admin/config/media/image-styles) and you will see the image styles that are defined by default.

Since we created four breakpoints in this example, we will also create four image styles in Drupal but you may create less or more. In order to serve the right image for the right screen size, we need to create different variations or image styles of the original image where each image style is the result of applying one or more effects (i.e scale, crop, resize, etc.) to the original image. Multiplier is the measure of the viewport's device resolution 1x is normal and 2x for HD and retina displays. Breakpoints with the smallest min-width should have the lowest weight, while breakpoints with the largest min-width should have a larger weight value. Out of them the weight property is really important and provides the value for the order in which breakpoints are arranged. Let’s create one such file in our custom_theme.Įxample (custom_): custom_theme.xs:Įach entry in this file defines one breakpoint, consisting the machine name for the breakpoint, label, media query, weight and multipliers. Instead, we can define breakpoints by creating a Config file called in a theme or module. Unfortunately, there is no user interface for editing breakpoints in Drupal 8. In Drupal 8/9 the Breakpoints module standardizes the use of breakpoints and enables modules and themes to expose or use each other's breakpoints. They are used to separate the width and height of viewports in a responsive design so that they are displayed correctly on different devices. To confirm or enable new modules, go to /admin/modulesīreakpoints are really just media queries with some additional metadata.

If you are using the Drupal /9 standard profile then the Breakpoint module is already enabled and, in this case, you only need to enable the Responsive Image module on your site. These two modules are part of Drupal 8 core and all we need is to enable them. 1. Enable the Breakpoint and Responsive Image modules
