SharePoint Online Modern Document Library View Formatting - Thumbnail Along With Extension Icon And Created By

Introduction

 
In the previous article, We looked at SharePoint Online Modern List View Formatting. In this article, we will explore SharePoint online modern Document Library view formatting in the modern experience. In SharePoint online modern format view, it’s now possible to change the shape, size, and colors, and add the other view properties.
 
This functionality is configurable in the Modern SharePoint list views available and document Library tiles display data.
 

Scenario

 
The customer requires the display of  document library files in Tiles view to show the file extension icon and the created-by fields of library in the view.
 

Objective

 
We have created a document library, “My Documents”,  and uploaded different extension files like word, powerpoint, excel, Image, video and Zip folder files.
 

Create a View

  1. Open the list in "All items" view and then, click thumbnail view (Tiles). By default select the save view as option.

  2. Follow the numerical points, as shown in the below screenshot,

    SharePoint Online Modern Document Library View Formatting - Thumbnail Along With Extension Icon And Created By

  3. Edit the Created Custom View to use the “Type (icon linked to document)” and “Created By” fields in the format view. You need to add them to the view. When editing in a quick edit view, include the “Name” field for identification of the File Name.

  4. Format JSON as per our requirements in JSON Editor
    1. {  
    2.   "$schema""https://developer.microsoft.com/json-schemas/sp/view-formatting.schema.json",  
    3.   "tileProps": {  
    4.     "hideSelection"true,  
    5.     "height""280",  
    6.     "width""300",  
    7.     "formatter": {  
    8.       "elmType""div",  
    9.       "style": {  
    10.         "align-items""stretch",  
    11.         "margin""3px 2px",  
    12.         "background-color""#fbfbfb",  
    13.         "height""380px",  
    14.         "overflow""inherit",  
    15.         "border-radius""2px",  
    16.         "box-shadow""0px 1.6px 3.6px 0 #00000024, 0px 0.3px 0.9px 0 #00000024"  
    17.       },  
    18.       "children": [  
    19.         {  
    20.           "elmType""div",  
    21.           "style": {  
    22.             "display""flex",  
    23.             "flex-wrap""wrap",  
    24.             "position""relative",  
    25.             "padding-bottom""10px",  
    26.             "width""100%"  
    27.           },  
    28.           "children": [  
    29.             {  
    30.               "elmType""div",  
    31.               "style": {  
    32.                 "margin-top""0px",  
    33.                 "height""200px",  
    34.                 "display""block",  
    35.                 "align-items""center",  
    36.                 "justify-content""center",  
    37.                 "position""relative",  
    38.                 "border-bottom""1px solid #EEE",  
    39.                 "overflow""hidden",  
    40.                 "border-radius""2px 2px 0 0"  
    41.               },  
    42.               "children": [  
    43.                 {  
    44.                   "elmType""button",  
    45.                   "style": {  
    46.                     "position""absolute",  
    47.                     "height""100%",  
    48.                     "width""100%",  
    49.                     "opacity""0",  
    50.                     "cursor""pointer"  
    51.                   },  
    52.                   "customRowAction": {  
    53.                     "action""defaultClick"  
    54.                   }  
    55.                 },  
    56.                 {  
    57.                   "elmType""div",  
    58.                   "style": {  
    59.                     "width""=if([$File_x0020_Type] == '', '100px', '100%')",  
    60.                     "height""=if([$File_x0020_Type] == '', '100px', '100%')",  
    61.                     "oveflow""=if([$File_x0020_Type] == '', 'auto', 'hidden')",  
    62.                     "text-align""center",  
    63.                     "overflow""hidden"  
    64.                   },  
    65.                   "children": [  
    66.                     {  
    67.                       "elmType""img",  
    68.                       "style": {  
    69.                         "height""=if([$File_x0020_Type] == '', '100%', '0'"  
    70.                       },  
    71.                       "attributes": {  
    72.                         "src""=if([$File_x0020_Type] == '', 'https://spoprod-a.akamaihd.net/files/fabric/office-ui-fabric-react-assets/foldericons-fluent/folder-large_frontplate_nopreview.svg', '')"  
    73.                       }  
    74.                     },  
    75.                     {  
    76.                       "elmType""img",  
    77.                       "style": {  
    78.                         "display""=if([$File_x0020_Type] == '', 'none', '')"  
    79.                       },  
    80.                       "attributes": {  
    81.                         "src""@thumbnail.383x383"  
    82.                       }  
    83.                     }  
    84.                   ]  
    85.                 }  
    86.               ]  
    87.             },  
    88.             {  
    89.               "elmType""div",  
    90.               "style": {  
    91.                 "margin""25px 0 0 0",  
    92.                 "position""absolute",  
    93.                 "top""153px",  
    94.                 "width""100%",  
    95.                 "color""#333333"  
    96.               },  
    97.               "attributes": {  
    98.                 "class""ms-fontSize-14 ms-fontWeight-semibold"  
    99.               },  
    100.               "children": [  
    101.                 {  
    102.                   "elmType""img",  
    103.                   "attributes": {  
    104.                     "src""=if([$File_x0020_Type] == 'docx', 'https://spoprod-a.akamaihd.net/files/fabric/assets/item-types-fluent/20/docx.svg?v6', if([$File_x0020_Type] == 'xlsx', 'https://spoprod-a.akamaihd.net/files/fabric/assets/item-types-fluent/20/xlsx.svg?v6', if([$File_x0020_Type] == 'pptx', 'https://spoprod-a.akamaihd.net/files/fabric/assets/item-types-fluent/20/pptx.svg?v6', if([$File_x0020_Type] == 'pdf', 'https://spoprod-a.akamaihd.net/files/fabric/assets/item-types-fluent/20/pdf.svg?v6', if([$File_x0020_Type] == 'jpg' || [$File_x0020_Type] == 'png' || [$File_x0020_Type] == 'gif','https://spoprod-a.akamaihd.net/files/fabric/assets/item-types-fluent/20/photo.svg?v6', if([$File_x0020_Type] == 'mp4' || [$File_x0020_Type] == 'avi' || [$File_x0020_Type] == 'mov', 'https://spoprod-a.akamaihd.net/files/fabric/assets/item-types-fluent/20/video.svg?v6', if([$File_x0020_Type] == 'zip', 'https://spoprod-a.akamaihd.net/files/fabric/assets/item-types-fluent/20/zip.svg?v6','Unknown')))))))"  
    105.                   },  
    106.                   "style": {  
    107.                     "flex""none",  
    108.                     "line-height""100%",  
    109.                     "font-weight""normal",  
    110.                     "font-size""2rem",  
    111.                     "margin""5px 5px 5px 10px",  
    112.                     "height""25px"  
    113.                   }  
    114.                 },  
    115.                 {  
    116.                   "elmType""div",  
    117.                   "txtContent""[$FileLeafRef]",  
    118.                   "style": {  
    119.                     "padding""0 0 0 16px"  
    120.                   }  
    121.                 },  
    122.                 {  
    123.                   "elmType""div",  
    124.                   "txtContent""='edited by ' + [$Editor.title]",  
    125.                   "style": {  
    126.                     "padding""0 0 0 16px"  
    127.                   }  
    128.                 }  
    129.               ]  
    130.             }  
    131.           ]  
    132.         }  
    133.       ]  
    134.     }  
    135.   }  
    136. }  

  5. It’s as simple as opening the MyDocuments Document library to open the view formatting pane. Then, open the view dropdown View Selector –>Select the Tiles -> “Format current view” option. Follow the numerical points, as shown in the below screenshot,

    SharePoint Online Modern Document Library View Formatting - Thumbnail Along With Extension Icon And Created By

  6. PAste  in the JSON that has already been constructed above-> click save button.

    SharePoint Online Modern Document Library View Formatting - Thumbnail Along With Extension Icon And Created By
Before formatting style of view
 
SharePoint Online Modern Document Library View Formatting - Thumbnail Along With Extension Icon And Created By
 
After formatting style of view
 
SharePoint Online Modern Document Library View Formatting - Thumbnail Along With Extension Icon And Created By