and trying to adapt it to use a different image. unfortunately my wordpress site isn’t secure yet, so I can’t read them from there. Any other good suggestions for a location to store them until I upgrade that site?
Meanwhile I’m trying to attach them to notebook but can’t reference them yet. I tried using await to no avail.
Here is my notebook: Story Visualizer / Bruce Crock | Observable
Here is a sample of the code I’ve tried:
slide.img${await FileAttachment("1967713290_a_creative_young_woman_and_machine_inventing_inspirational_computer_aided_design_solutions_to_save_t-transformed.jpeg").image()}
[Setting aside ‘slide’ for the moment, and taking this in turn]
Any other good suggestions for a location to store them until I upgrade that site?
If your images are smaller than 50MB, you can upload them directly into a notebook as a file attachment (seems you’re on the right track in doing this based on your next comment, but for reference):
Meanwhile I’m trying to attach them to notebook but can’t reference them yet.
… you definitely seem to have this working, just maybe you’re not using the JavaScript cell type?
FileAttachment("Picture1.png").image()
… will work if your cell is a JavaScript cell (otherwise it will likely just look like text). For reference:
[Now, back to ‘slide’]:
Step 1. In a JavaScript cell, import the slide functions (you do this correctly, so just writing for good measure for any others):
import {slide, slide_style} from "@mbostock/slide"
Step 2:
… then, notice that the working patterns in Mike’s notebook expect the image as a URL. So we can’t just enter in the rendered images for the slide function to work, we must give it a URL:
Thanks so much for that help. Looks like file attachments will work well for me for the time being. I am clear on the difference between HTML vs js cells and I haven’t been consistent so it’s good to pay close attention.
Also, It makes sense that the slide object is looking for a URL, and thanks for showing me how to do that.
My next task was to load a set of images from attachments into an array so I can page through them. I struggled with it a bit and I am curious what it is about the way I wrote “storyImages5” that works while the way I wrote “storyImages4” doesn’t work.
In this way, you would be returning the promise of rendered image, so if you paste, e.g. storyImage4asPromise[2].img into a JavaScript cell, you’ll see you image. If you wish for this to render in a Markdown cell, you’d need to escape into JavaScript and await the promise: ${await storyImagesPromise[2].img}