diff --git a/api_docs/changelog.md b/api_docs/changelog.md index dba6d76e08..7e4161582c 100644 --- a/api_docs/changelog.md +++ b/api_docs/changelog.md @@ -20,6 +20,12 @@ format used by the Zulip server that they are interacting with. ## Changes in Zulip 9.0 +**Feature level 276** + +* [Markdown message formatting](/api/message-formatting#image-previews): + Image preview elements not contain a `data-original-dimensions` + attribute containing the dimensions of the original image. + **Feature level 275** * [`POST /register`](/api/register-queue), [`PATCH diff --git a/version.py b/version.py index cdc2fce7a0..6d8b2deaa4 100644 --- a/version.py +++ b/version.py @@ -34,7 +34,7 @@ DESKTOP_WARNING_VERSION = "5.9.3" # new level means in api_docs/changelog.md, as well as "**Changes**" # entries in the endpoint's documentation in `zulip.yaml`. -API_FEATURE_LEVEL = 275 # Last bumped for `web_animate_image_previews` setting. +API_FEATURE_LEVEL = 276 # Last bumped for data-original-dimensions # Bump the minor PROVISION_VERSION to indicate that folks should provision diff --git a/zerver/lib/thumbnail.py b/zerver/lib/thumbnail.py index 7718fc02bd..fd18392fe0 100644 --- a/zerver/lib/thumbnail.py +++ b/zerver/lib/thumbnail.py @@ -329,6 +329,8 @@ def split_thumbnail_path(file_path: str) -> tuple[str, BaseThumbnailFormat]: class MarkdownImageMetadata: url: str is_animated: bool + original_width_px: int + original_height_px: int def get_user_upload_previews( @@ -347,6 +349,8 @@ def get_user_upload_previews( upload_preview_data[image_attachment.path_id] = MarkdownImageMetadata( url=url, is_animated=is_animated, + original_width_px=image_attachment.original_width_px, + original_height_px=image_attachment.original_height_px, ) return upload_preview_data @@ -421,6 +425,9 @@ def rewrite_thumbnailed_images( changed = True del image_tag["class"] image_tag["src"] = image_data.url + image_tag["data-original-dimensions"] = ( + f"{image_data.original_width_px}x{image_data.original_height_px}" + ) if image_data.is_animated: image_tag["data-animated"] = "true" diff --git a/zerver/tests/test_markdown_thumbnail.py b/zerver/tests/test_markdown_thumbnail.py index b352b1c0eb..b68d4a3e21 100644 --- a/zerver/tests/test_markdown_thumbnail.py +++ b/zerver/tests/test_markdown_thumbnail.py @@ -73,15 +73,15 @@ class MarkdownThumbnailTest(ZulipTestCase): "
Test 1
\n"
f'{image_names[0]}
Next image
\n"
f'{image_names[1]}
Another screenshot
\n"
f'{image_names[2]}
first image
\n'
f'second image