Skip to content

Commit dea2974

Browse files
authored
Update README.md
Added properties to image() and added zip()
1 parent 46a7bba commit dea2974

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

README.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -336,10 +336,10 @@ If <i>array</i> is true, an array of arrays is returned; otherwise, the first ro
336336

337337
<a href="#attachment_image" name="attachment_image">#</a> *attachment*.<b>image</b>() [<>](https://github.com/observablehq/stdlib/blob/main/src/fileAttachment.mjs "Source")
338338

339-
Returns a promise to a file loaded as an [Image](https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/Image). The promise resolves when the image has finished loading, making this useful for reading the image pixels in Canvas, or for loading the image into a WebGL texture. Consider [*attachment*.url](#attachment_url) if you want to embed an image in HTML or Markdown.
339+
Returns a promise to a file loaded as an [Image](https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/Image). The promise resolves when the image has finished loading, making this useful for reading the image pixels in Canvas, or for loading the image into a WebGL texture. Consider [*attachment*.url](#attachment_url) if you want to embed an image in HTML or Markdown. Image properties can be passed in as JavaScript properties.
340340

341341
```js
342-
const image = await FileAttachment("sunset.jpg").image();
342+
const image = await FileAttachment("sunset.jpg").image({width: 400, style: "border: 1px solid black"});
343343
```
344344

345345
<a href="#attachment_arrayBuffer" name="attachment_arrayBuffer">#</a> *attachment*.<b>arrayBuffer</b>() [<>](https://github.com/observablehq/stdlib/blob/main/src/fileAttachment.mjs "Source")
@@ -400,6 +400,16 @@ const document = await FileAttachment("cars.xml").xml();
400400

401401
Returns a promise to an [HTMLDocument](https://developer.mozilla.org/en-US/docs/Web/API/HTMLDocument) containing the contents of the file.
402402

403+
```js
404+
const archive = await FileAttachment("archive.zip").zip();
405+
const fileNames = archive.filenames;
406+
const readMe = archive.file("Readme.txt").text();
407+
```
408+
409+
<a href="#attachment_zip" name="attachment_zip">#</a> *attachment*.<b>zip</b>() [<>](https://github.com/observablehq/stdlib/blob/main/src/fileAttachment.mjs "Source")
410+
411+
Returns a promise to a list of Files in the ZIP archive. Files can be read from the archive.
412+
403413
```js
404414
const document = await FileAttachment("index.html").html();
405415
```

0 commit comments

Comments
 (0)