@@ -262,7 +262,8 @@ class ContentExample {
262262 nodes: [TextNode ('image' )]),
263263 ]),
264264 ImageNodeList ([
265- ImageNode (srcUrl: 'https://chat.zulip.org/user_avatars/2/realm/icon.png?version=3' ),
265+ ImageNode (srcUrl: 'https://chat.zulip.org/user_avatars/2/realm/icon.png?version=3' ,
266+ thumbnailUrl: null , loading: false ),
266267 ]),
267268 ],
268269 content: [ParagraphNode (links: null , nodes: [TextNode ('hello world' )])],
@@ -420,12 +421,53 @@ class ContentExample {
420421
421422 static const imageSingle = ContentExample (
422423 'single image' ,
424+ // https://chat.zulip.org/#narrow/stream/7-test-here/topic/Thumbnails/near/1893590
425+ "[image.jpg](/user_uploads/2/c3/wb9FXk8Ej6qIc28aWKcqUogD/image.jpg)" ,
426+ '<div class="message_inline_image">'
427+ '<a href="/user_uploads/2/c3/wb9FXk8Ej6qIc28aWKcqUogD/image.jpg" title="image.jpg">'
428+ '<img src="/user_uploads/thumbnail/2/c3/wb9FXk8Ej6qIc28aWKcqUogD/image.jpg/840x560.webp"/></a></div>' , [
429+ ImageNodeList ([
430+ ImageNode (srcUrl: '/user_uploads/2/c3/wb9FXk8Ej6qIc28aWKcqUogD/image.jpg' ,
431+ thumbnailUrl: '/user_uploads/thumbnail/2/c3/wb9FXk8Ej6qIc28aWKcqUogD/image.jpg/840x560.webp' ,
432+ loading: false ),
433+ ]),
434+ ]);
435+
436+ static const imageSingleNoThumbnail = ContentExample (
437+ 'single image no thumbnail' ,
423438 "https://chat.zulip.org/user_avatars/2/realm/icon.png?version=3" ,
424439 '<div class="message_inline_image">'
425440 '<a href="https://chat.zulip.org/user_avatars/2/realm/icon.png?version=3">'
426441 '<img src="https://chat.zulip.org/user_avatars/2/realm/icon.png?version=3"></a></div>' , [
427442 ImageNodeList ([
428- ImageNode (srcUrl: 'https://chat.zulip.org/user_avatars/2/realm/icon.png?version=3' ),
443+ ImageNode (srcUrl: 'https://chat.zulip.org/user_avatars/2/realm/icon.png?version=3' ,
444+ thumbnailUrl: null , loading: false ),
445+ ]),
446+ ]);
447+
448+ static const imageSingleLoadingPlaceholder = ContentExample (
449+ 'single image loading placeholder' ,
450+ // https://chat.zulip.org/#narrow/stream/7-test-here/topic/Thumbnails/near/1893590
451+ "[image.jpg](/user_uploads/2/c3/wb9FXk8Ej6qIc28aWKcqUogD/image.jpg)" ,
452+ '<div class="message_inline_image">'
453+ '<a href="/user_uploads/2/c3/wb9FXk8Ej6qIc28aWKcqUogD/image.jpg" title="image.jpg">'
454+ '<img class="image-loading-placeholder" src="/static/images/loading/loader-black.svg"></a></div>' , [
455+ ImageNodeList ([
456+ ImageNode (srcUrl: '/user_uploads/2/c3/wb9FXk8Ej6qIc28aWKcqUogD/image.jpg' ,
457+ thumbnailUrl: null , loading: true ),
458+ ]),
459+ ]);
460+
461+ static const imageSingleExternal = ContentExample (
462+ 'single image external' ,
463+ // https://chat.zulip.org/#narrow/stream/7-test-here/topic/Greg/near/1892172
464+ "https://upload.wikimedia.org/wikipedia/commons/7/78/Verregende_bloem_van_een_Helenium_%27El_Dorado%27._22-07-2023._%28d.j.b%29.jpg" ,
465+ '<div class="message_inline_image">'
466+ '<a href="https://upload.wikimedia.org/wikipedia/commons/7/78/Verregende_bloem_van_een_Helenium_%27El_Dorado%27._22-07-2023._%28d.j.b%29.jpg">'
467+ '<img src="/external_content/de28eb3abf4b7786de4545023dc42d434a2ea0c2/68747470733a2f2f75706c6f61642e77696b696d656469612e6f72672f77696b6970656469612f636f6d6d6f6e732f372f37382f566572726567656e64655f626c6f656d5f76616e5f65656e5f48656c656e69756d5f253237456c5f446f7261646f2532372e5f32322d30372d323032332e5f253238642e6a2e622532392e6a7067"></a></div>' , [
468+ ImageNodeList ([
469+ ImageNode (srcUrl: '/external_content/de28eb3abf4b7786de4545023dc42d434a2ea0c2/68747470733a2f2f75706c6f61642e77696b696d656469612e6f72672f77696b6970656469612f636f6d6d6f6e732f372f37382f566572726567656e64655f626c6f656d5f76616e5f65656e5f48656c656e69756d5f253237456c5f446f7261646f2532372e5f32322d30372d323032332e5f253238642e6a2e622532392e6a7067' ,
470+ thumbnailUrl: null , loading: false ),
429471 ]),
430472 ]);
431473
@@ -436,12 +478,41 @@ class ContentExample {
436478 '<a href="::not a URL::">'
437479 '<img src="::not a URL::"></a></div>' , [
438480 ImageNodeList ([
439- ImageNode (srcUrl: '::not a URL::' ),
481+ ImageNode (srcUrl: '::not a URL::' , thumbnailUrl : null , loading : false ),
440482 ]),
441483 ]);
442484
443485 static const imageCluster = ContentExample (
444486 'multiple images' ,
487+ // https://chat.zulip.org/#narrow/stream/7-test-here/topic/Thumbnails/near/1893154
488+ "[image.jpg](/user_uploads/2/9b/WkDt2Qsy79iwf3sM9EMp9fYL/image.jpg)\n [image2.jpg](/user_uploads/2/70/pVeI52TwFUEoFE2qT_u9AMCO/image2.jpg)" ,
489+ '<p>'
490+ '<a href="/user_uploads/2/9b/WkDt2Qsy79iwf3sM9EMp9fYL/image.jpg">image.jpg</a><br/>\n '
491+ '<a href="/user_uploads/2/70/pVeI52TwFUEoFE2qT_u9AMCO/image2.jpg">image2.jpg</a></p>\n '
492+ '<div class="message_inline_image">'
493+ '<a href="/user_uploads/2/9b/WkDt2Qsy79iwf3sM9EMp9fYL/image.jpg" title="image.jpg">'
494+ '<img src="/user_uploads/thumbnail/2/9b/WkDt2Qsy79iwf3sM9EMp9fYL/image.jpg/840x560.webp"/></a></div>'
495+ '<div class="message_inline_image">'
496+ '<a href="/user_uploads/2/70/pVeI52TwFUEoFE2qT_u9AMCO/image2.jpg" title="image2.jpg">'
497+ '<img src="/user_uploads/thumbnail/2/70/pVeI52TwFUEoFE2qT_u9AMCO/image2.jpg/840x560.webp"/></a></div>' , [
498+ ParagraphNode (links: null , nodes: [
499+ LinkNode (url: '/user_uploads/2/9b/WkDt2Qsy79iwf3sM9EMp9fYL/image.jpg' , nodes: [TextNode ('image.jpg' )]),
500+ LineBreakInlineNode (),
501+ TextNode ('\n ' ),
502+ LinkNode (url: '/user_uploads/2/70/pVeI52TwFUEoFE2qT_u9AMCO/image2.jpg' , nodes: [TextNode ('image2.jpg' )]),
503+ ]),
504+ ImageNodeList ([
505+ ImageNode (srcUrl: '/user_uploads/2/9b/WkDt2Qsy79iwf3sM9EMp9fYL/image.jpg' ,
506+ thumbnailUrl: '/user_uploads/thumbnail/2/9b/WkDt2Qsy79iwf3sM9EMp9fYL/image.jpg/840x560.webp' ,
507+ loading: false ),
508+ ImageNode (srcUrl: '/user_uploads/2/70/pVeI52TwFUEoFE2qT_u9AMCO/image2.jpg' ,
509+ thumbnailUrl: '/user_uploads/thumbnail/2/70/pVeI52TwFUEoFE2qT_u9AMCO/image2.jpg/840x560.webp' ,
510+ loading: false ),
511+ ]),
512+ ]);
513+
514+ static const imageClusterNoThumbnails = ContentExample (
515+ 'multiple images no thumbnails' ,
445516 "https://chat.zulip.org/user_avatars/2/realm/icon.png?version=3\n https://chat.zulip.org/user_avatars/2/realm/icon.png?version=4" ,
446517 '<p>'
447518 '<a href="https://chat.zulip.org/user_avatars/2/realm/icon.png?version=3">https://chat.zulip.org/user_avatars/2/realm/icon.png?version=3</a><br>\n '
@@ -459,8 +530,10 @@ class ContentExample {
459530 LinkNode (url: 'https://chat.zulip.org/user_avatars/2/realm/icon.png?version=4' , nodes: [TextNode ('https://chat.zulip.org/user_avatars/2/realm/icon.png?version=4' )]),
460531 ]),
461532 ImageNodeList ([
462- ImageNode (srcUrl: 'https://uploads.zulipusercontent.net/f535ba07f95b99a83aa48e44fd62bbb6c6cf6615/68747470733a2f2f636861742e7a756c69702e6f72672f757365725f617661746172732f322f7265616c6d2f69636f6e2e706e673f76657273696f6e3d33' ),
463- ImageNode (srcUrl: 'https://uploads.zulipusercontent.net/8f63bc2632a0e41be3f457d86c077e61b4a03e7e/68747470733a2f2f636861742e7a756c69702e6f72672f757365725f617661746172732f322f7265616c6d2f69636f6e2e706e673f76657273696f6e3d34' ),
533+ ImageNode (srcUrl: 'https://uploads.zulipusercontent.net/f535ba07f95b99a83aa48e44fd62bbb6c6cf6615/68747470733a2f2f636861742e7a756c69702e6f72672f757365725f617661746172732f322f7265616c6d2f69636f6e2e706e673f76657273696f6e3d33' ,
534+ thumbnailUrl: null , loading: false ),
535+ ImageNode (srcUrl: 'https://uploads.zulipusercontent.net/8f63bc2632a0e41be3f457d86c077e61b4a03e7e/68747470733a2f2f636861742e7a756c69702e6f72672f757365725f617661746172732f322f7265616c6d2f69636f6e2e706e673f76657273696f6e3d34' ,
536+ thumbnailUrl: null , loading: false ),
464537 ]),
465538 ]);
466539
@@ -484,8 +557,10 @@ class ContentExample {
484557 LinkNode (url: 'https://chat.zulip.org/user_avatars/2/realm/icon.png?version=2' , nodes: [TextNode ('icon.png' )]),
485558 ]),
486559 ImageNodeList ([
487- ImageNode (srcUrl: 'https://chat.zulip.org/user_avatars/2/realm/icon.png' ),
488- ImageNode (srcUrl: 'https://chat.zulip.org/user_avatars/2/realm/icon.png?version=2' ),
560+ ImageNode (srcUrl: 'https://chat.zulip.org/user_avatars/2/realm/icon.png' ,
561+ thumbnailUrl: null , loading: false ),
562+ ImageNode (srcUrl: 'https://chat.zulip.org/user_avatars/2/realm/icon.png?version=2' ,
563+ thumbnailUrl: null , loading: false ),
489564 ]),
490565 ParagraphNode (links: null , nodes: [
491566 TextNode ('more content' ),
@@ -520,8 +595,10 @@ class ContentExample {
520595 LinkNode (url: 'https://en.wikipedia.org/static/images/icons/wikipedia.png?v=1' , nodes: [TextNode ('https://en.wikipedia.org/static/images/icons/wikipedia.png?v=1' )]),
521596 ]),
522597 ImageNodeList ([
523- ImageNode (srcUrl: 'https://uploads.zulipusercontent.net/34b2695ca83af76204b0b25a8f2019ee35ec38fa/68747470733a2f2f656e2e77696b6970656469612e6f72672f7374617469632f696d616765732f69636f6e732f77696b6970656469612e706e67' ),
524- ImageNode (srcUrl: 'https://uploads.zulipusercontent.net/d200fb112aaccbff9df767373a201fa59601f362/68747470733a2f2f656e2e77696b6970656469612e6f72672f7374617469632f696d616765732f69636f6e732f77696b6970656469612e706e673f763d31' ),
598+ ImageNode (srcUrl: 'https://uploads.zulipusercontent.net/34b2695ca83af76204b0b25a8f2019ee35ec38fa/68747470733a2f2f656e2e77696b6970656469612e6f72672f7374617469632f696d616765732f69636f6e732f77696b6970656469612e706e67' ,
599+ thumbnailUrl: null , loading: false ),
600+ ImageNode (srcUrl: 'https://uploads.zulipusercontent.net/d200fb112aaccbff9df767373a201fa59601f362/68747470733a2f2f656e2e77696b6970656469612e6f72672f7374617469632f696d616765732f69636f6e732f77696b6970656469612e706e673f763d31' ,
601+ thumbnailUrl: null , loading: false ),
525602 ]),
526603 ParagraphNode (links: null , nodes: [
527604 TextNode ('Test' ),
@@ -533,8 +610,10 @@ class ContentExample {
533610 LinkNode (url: 'https://en.wikipedia.org/static/images/icons/wikipedia.png?v=3' , nodes: [TextNode ('https://en.wikipedia.org/static/images/icons/wikipedia.png?v=3' )]),
534611 ]),
535612 ImageNodeList ([
536- ImageNode (srcUrl: 'https://uploads.zulipusercontent.net/c4db87e81348dac94eacaa966b46d968b34029cc/68747470733a2f2f656e2e77696b6970656469612e6f72672f7374617469632f696d616765732f69636f6e732f77696b6970656469612e706e673f763d32' ),
537- ImageNode (srcUrl: 'https://uploads.zulipusercontent.net/51b70540cf6a5b3c8a0b919c893b8abddd447e88/68747470733a2f2f656e2e77696b6970656469612e6f72672f7374617469632f696d616765732f69636f6e732f77696b6970656469612e706e673f763d33' ),
613+ ImageNode (srcUrl: 'https://uploads.zulipusercontent.net/c4db87e81348dac94eacaa966b46d968b34029cc/68747470733a2f2f656e2e77696b6970656469612e6f72672f7374617469632f696d616765732f69636f6e732f77696b6970656469612e706e673f763d32' ,
614+ thumbnailUrl: null , loading: false ),
615+ ImageNode (srcUrl: 'https://uploads.zulipusercontent.net/51b70540cf6a5b3c8a0b919c893b8abddd447e88/68747470733a2f2f656e2e77696b6970656469612e6f72672f7374617469632f696d616765732f69636f6e732f77696b6970656469612e706e673f763d33' ,
616+ thumbnailUrl: null , loading: false ),
538617 ]),
539618 ]);
540619
@@ -548,7 +627,8 @@ class ContentExample {
548627 '<img src="https://chat.zulip.org/user_avatars/2/realm/icon.png"></a></div></li>\n </ul>' , [
549628 ListNode (ListStyle .unordered, [[
550629 ImageNodeList ([
551- ImageNode (srcUrl: 'https://chat.zulip.org/user_avatars/2/realm/icon.png' ),
630+ ImageNode (srcUrl: 'https://chat.zulip.org/user_avatars/2/realm/icon.png' ,
631+ thumbnailUrl: null , loading: false ),
552632 ]),
553633 ]]),
554634 ]);
@@ -573,8 +653,10 @@ class ContentExample {
573653 LinkNode (url: 'https://chat.zulip.org/user_avatars/2/realm/icon.png?version=2' , nodes: [TextNode ('icon.png' )]),
574654 ]),
575655 ImageNodeList ([
576- ImageNode (srcUrl: 'https://chat.zulip.org/user_avatars/2/realm/icon.png' ),
577- ImageNode (srcUrl: 'https://chat.zulip.org/user_avatars/2/realm/icon.png?version=2' ),
656+ ImageNode (srcUrl: 'https://chat.zulip.org/user_avatars/2/realm/icon.png' ,
657+ thumbnailUrl: null , loading: false ),
658+ ImageNode (srcUrl: 'https://chat.zulip.org/user_avatars/2/realm/icon.png?version=2' ,
659+ thumbnailUrl: null , loading: false ),
578660 ]),
579661 ]]),
580662 ]);
@@ -597,7 +679,8 @@ class ContentExample {
597679 TextNode (' ' ),
598680 ]),
599681 const ImageNodeList ([
600- ImageNode (srcUrl: 'https://chat.zulip.org/user_avatars/2/realm/icon.png' ),
682+ ImageNode (srcUrl: 'https://chat.zulip.org/user_avatars/2/realm/icon.png' ,
683+ thumbnailUrl: null , loading: false ),
601684 ]),
602685 blockUnimplemented ('more text' ),
603686 ]]),
@@ -1034,8 +1117,12 @@ void main() {
10341117 testParseExample (ContentExample .mathBlockInQuote);
10351118
10361119 testParseExample (ContentExample .imageSingle);
1120+ testParseExample (ContentExample .imageSingleNoThumbnail);
1121+ testParseExample (ContentExample .imageSingleLoadingPlaceholder);
1122+ testParseExample (ContentExample .imageSingleExternal);
10371123 testParseExample (ContentExample .imageInvalidUrl);
10381124 testParseExample (ContentExample .imageCluster);
1125+ testParseExample (ContentExample .imageClusterNoThumbnails);
10391126 testParseExample (ContentExample .imageClusterThenContent);
10401127 testParseExample (ContentExample .imageMultipleClusters);
10411128 testParseExample (ContentExample .imageInImplicitParagraph);
0 commit comments