Add local image preview and auto-conversion to node editor and local loopback browsing

This commit is contained in:
Mark Qvist committed 2026-09-10 19:14:51 +02:00
1 parent abb1d3b923
commit 379bf9318e
2 files changed
+9

No files matched your search

+7
View File
@@ -864,6 +864,13 @@ class Browser:
if image_destination_hash == self.loopback:
local_image = path.replace("/media/", "")
local_path = f"{self.app.pagespath}/{local_image}"
if self.app.node:
image_ext = os.path.splitext(local_path)[-1]
if not image_ext in self.app.node.NATIVE_MEDIA_EXTS:
RNS.log(f"Non-native media type for {local_path}, attempting auto-conversion", RNS.LOG_DEBUG)
local_path = self.app.node.convert_media_to_webp(local_path)
if self.image_rendering_supported:
w.load(local_path)
self.refresh_page_layout()
+2
View File
@@ -445,6 +445,8 @@ class PageEditorDisplay():
self.register_styles()
self.preview_browser = Browser(self.app, "nomadnetwork", "node", delegate=None)
self.preview_browser.loopback = self.app.node.destination.hash
self.preview_browser.destination_hash = self.app.node.destination.hash
self.preview_browser.handle_link = self._preview_handle_link
self.preview_browser.marked_link = lambda *a, **k: None
self.preview_browser._content_cols = self._preview_cols