Skip to content

Commit d0628fa

Browse files
authored
Merge pull request #39 from Unity-Lab-AI/codex/fix-screensaver-image-loading-issues
Fix screensaver image URL generation
2 parents d4d446e + 3cfab6e commit d0628fa

File tree

1 file changed

+21
-7
lines changed

1 file changed

+21
-7
lines changed

js/ui/screensaver.js

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -252,21 +252,35 @@ document.addEventListener("DOMContentLoaded", () => {
252252
const enhance = settings.enhance;
253253
const priv = settings.priv;
254254

255-
// Build the image URL via polliLib MCP helper (no direct endpoint usage)
256-
const url = (function(){
255+
// Build the image URL via polliLib MCP helper; fallback to direct Pollinations endpoint
256+
const url = await (async () => {
257257
try {
258258
if (window.polliLib && window.polliClient) {
259-
return window.polliLib.mcp.generateImageUrl(window.polliClient, {
259+
return await window.polliLib.mcp.generateImageUrl(window.polliClient, {
260260
prompt,
261-
width, height, seed, model,
261+
width,
262+
height,
263+
seed,
264+
model,
262265
nologo: true,
263266
private: priv,
264267
enhance: !!enhance
265268
});
266269
}
267-
} catch (e) { console.warn('polliLib generateImageUrl failed', e); }
268-
// Fallback to placeholder if polliLib not available
269-
return "https://via.placeholder.com/512?text=Image+Unavailable";
270+
} catch (e) {
271+
console.warn('polliLib generateImageUrl failed', e);
272+
}
273+
const base = `https://image.pollinations.ai/prompt/${encodeURIComponent(prompt)}`;
274+
const params = new URLSearchParams({
275+
width,
276+
height,
277+
seed,
278+
model: model || 'flux',
279+
nologo: 'true',
280+
private: String(priv),
281+
enhance: String(!!enhance)
282+
});
283+
return `${base}?${params.toString()}`;
270284
})();
271285
console.log("Generated new image URL via polliLib:", url);
272286

0 commit comments

Comments
 (0)