Sunday 8 July 2018

Sitecore image getting black border on top and bottom?

Sometimes it happens that you may be getting black border on top and bottom of  an sitecore image item.

This is because of different height/width of original image. By default you will get black colour on top and bottom of an image.
There is setting for this in sitecore.config
Inside config you will get this below settings
<!--  MEDIA - DEFAULT IMAGE BACKGROUND COLOR
           The default background color for dynamically resizing images to different aspect ratios than the originals.



           Sitecore applies this background color only for image types that do not support transparency (image/jpeg, image/gif and image/bmp).
           When resizing any other image types (including image/png), Sitecore always applies a transparent background.
           You can specify a color name (such as Black or Red) or a hex color code (such as #CE55E2).
           If you specify no value, Sitecore applies a black background color when resizing such images.
           Default value: ""
     -->
       <setting name="Media.DefaultImageBackgroundColor" value="" />

By default value is empty and that's why you are getting black colour. So you can change color by setting value.