File tree Expand file tree Collapse file tree 2 files changed +31
-2
lines changed Expand file tree Collapse file tree 2 files changed +31
-2
lines changed Original file line number Diff line number Diff line change @@ -13,7 +13,12 @@ const Asset: React.FC<{ block: BlockType }> = ({ block }) => {
1313 }
1414
1515 const format = value . format ;
16- const { block_width, block_height, display_source } = format ;
16+ const {
17+ block_width,
18+ block_height,
19+ display_source,
20+ block_aspect_ratio
21+ } = format ;
1722
1823 const isImage = type === "image" ;
1924
@@ -37,7 +42,21 @@ const Asset: React.FC<{ block: BlockType }> = ({ block }) => {
3742
3843 if ( type === "image" ) {
3944 const caption = value . properties . caption ?. [ 0 ] [ 0 ] ;
40- return < img style = { style } alt = { caption } src = { src } /> ;
45+ if ( block_aspect_ratio ) {
46+ return (
47+ < div
48+ style = { {
49+ ...style ,
50+ paddingBottom : `${ block_aspect_ratio * 100 } %` ,
51+ position : "relative"
52+ } }
53+ >
54+ < img className = "notion-image-inset" alt = { caption } src = { src } />
55+ </ div >
56+ ) ;
57+ } else {
58+ return < img style = { style } alt = { caption } src = { src } /> ;
59+ }
4160 }
4261
4362 if ( type === "video" ) {
Original file line number Diff line number Diff line change @@ -211,6 +211,16 @@ li {
211211.notion-spacer : last-child {
212212 display : none;
213213}
214+
215+ .notion-image-inset {
216+ position : absolute;
217+ left : 0 ;
218+ top : 0 ;
219+ right : 0 ;
220+ bottom : 0 ;
221+ width : 100% ;
222+ }
223+
214224.notion-image-caption {
215225 padding : 6px 0px ;
216226 white-space : pre-wrap;
You can’t perform that action at this time.
0 commit comments