diff --git a/yazi-plugin/preset/plugins/image.lua b/yazi-plugin/preset/plugins/image.lua index 2d1a9d27..2ebfcb33 100644 --- a/yazi-plugin/preset/plugins/image.lua +++ b/yazi-plugin/preset/plugins/image.lua @@ -1,8 +1,12 @@ local M = {} function M:peek() - local cache = ya.file_cache(self) - ya.image_show(fs.symlink_metadata(cache) and cache or self.file.url, self.area) + local url = ya.file_cache(self) + if not url or not fs.symlink_metadata(url) then + url = self.file.url + end + + ya.image_show(url, self.area) ya.preview_widgets(self, {}) end @@ -10,7 +14,7 @@ function M:seek() end function M:preload() local cache = ya.file_cache(self) - if fs.symlink_metadata(cache) then + if not cache or fs.symlink_metadata(cache) then return 1 end diff --git a/yazi-plugin/preset/plugins/pdf.lua b/yazi-plugin/preset/plugins/pdf.lua index b4e37d5d..62fea107 100644 --- a/yazi-plugin/preset/plugins/pdf.lua +++ b/yazi-plugin/preset/plugins/pdf.lua @@ -1,8 +1,13 @@ local M = {} function M:peek() + local cache = ya.file_cache(self) + if not cache then + return + end + if self:preload() == 1 then - ya.image_show(ya.file_cache(self), self.area) + ya.image_show(cache, self.area) ya.preview_widgets(self, {}) end end @@ -17,7 +22,7 @@ end function M:preload() local cache = ya.file_cache(self) - if fs.symlink_metadata(cache) then + if not cache or fs.symlink_metadata(cache) then return 1 end diff --git a/yazi-plugin/preset/plugins/video.lua b/yazi-plugin/preset/plugins/video.lua index 46a3a02b..04695a13 100644 --- a/yazi-plugin/preset/plugins/video.lua +++ b/yazi-plugin/preset/plugins/video.lua @@ -1,8 +1,13 @@ local M = {} function M:peek() + local cache = ya.file_cache(self) + if not cache then + return + end + if self:preload() == 1 then - ya.image_show(ya.file_cache(self), self.area) + ya.image_show(cache, self.area) ya.preview_widgets(self, {}) end end @@ -25,7 +30,7 @@ function M:preload() end local cache = ya.file_cache(self) - if fs.symlink_metadata(cache) then + if not cache or fs.symlink_metadata(cache) then return 1 end