From 29b73aebd3d22d8b9338048531a017824e88fdb4 Mon Sep 17 00:00:00 2001 From: Zach Leatherman Date: Tue, 30 Jul 2024 10:32:19 -0500 Subject: [PATCH] Fix for remote image already in disk cache, still should return buffer in output. Caused issues with on-request image optimization --- img.js | 6 +++--- src/on-request-during-serve-plugin.js | 3 +++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/img.js b/img.js index 7ea5cf2..2344d7b 100644 --- a/img.js +++ b/img.js @@ -164,12 +164,12 @@ class Image { return JSON.stringify(opts); } - getFileContents(overridePath) { - if(this.isRemoteUrl) { + getFileContents(overrideLocalFilePath) { + if(!overrideLocalFilePath && this.isRemoteUrl) { return false; } - let src = overridePath || this.src; + let src = overrideLocalFilePath || this.src; if(!this._contents) { this._contents = {}; } diff --git a/src/on-request-during-serve-plugin.js b/src/on-request-during-serve-plugin.js index 057721b..ad2caff 100644 --- a/src/on-request-during-serve-plugin.js +++ b/src/on-request-during-serve-plugin.js @@ -72,6 +72,9 @@ function eleventyImageOnRequestDuringServePlugin(eleventyConfig, options = {}) { if(!stat) { throw new Error("Invalid image format."); } + if(!stat.buffer) { + throw new Error("Could not find `buffer` property for image."); + } return { headers: {