FileAttachment(selection).image()
// also tried String casting:
// FileAttachment(`${selection}`).image()
But I get the following error: SyntaxError: FileAttachment() requires a single literal string as its argument.
So, is it that FileAttachment do not like reactive argument ?
And what alternative could I use ?
I created a notebook for this issue here: Observable
I’ve came across this problem once. As noted by @mootari, if you read on the doc about FileAttachment you can find this paragraph
References to files are parsed statically. We use static analysis to determine which files a notebook uses so that we can automatically publish referenced files when a notebook is published (and only referenced files), and similarly copy only referenced files when forking a notebook. The FileAttachment function thus accepts only literal strings; code such as
FileAttachment("my" + "file.csv")
or similar dynamic invocation is invalid syntax. For details on how this is implemented, see our parser.
If you want the selection to come from the same cell you could try this pattern