Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
const url = ""
const req = new Request(url)
const { img: imgUrl } = await req.loadJSON()
const imgReq = await new Request(imgUrl)
const img = await imgReq.loadImage()
// for development, displays the widget if run
const debug = false;
if (config.runsInWidget) {
// create and show widget
let widget = createWidget(img)
} else if (debug) {
let widget = createWidget(img);
await widget.presentMedium();
} else {
function createWidget(img) {
let widget = new ListWidget();
widget.url = imgUrl;
let image = widget.addImage(img);
const [width, height] = getDimensions(config.widgetFamily);
image.imageSize = new Size(width, height);
return widget;
function getDimensions(size) {
switch (size) {
case "small":
return [150, 150];
case "medium":
return [300, 150];
case "large":
return [300, 300];
return [150, 150];

This comment has been minimized.

Copy link

@bendiscover bendiscover commented Mar 15, 2021

I get an error. "widget.centerAlignContent()" is undefined/not a function


This comment has been minimized.

Copy link
Owner Author

@rudotriton rudotriton commented Mar 16, 2021

@bendiscover Honestly, I forgot I had this here, but I updated it, so now it looks like my current widget script.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment