Now, we will see how we can add a custom image style with code:
The first thing we need to do is delete the small image style that we just created. So, open your d8dev site in your favorite browser, click on the Configuration link in the Admin toolbar, and then click on the Image styles link under the Media section.
Once the Image styles administrative page has loaded, click on the delete link for the small image style that we just added.
Next, on the Optionally select a style before deleting small page, leave the default value for the Replacement style select list as No replacement, just delete, and click on the Delete button:
In Drupal 8, image styles have been converted from an array to an object that extends ConfigEntity. All image styles provided by modules need to be defined as YAML configuration files in the
config/install
folder of each module.Suppose our module is located at
modules/d8dev
. Create a file calledmodules/d8dev...