Skip to content

Commit fdd8226

Browse files
CobusTmbostock
andauthored
add attributes to image() as options (#267)
* add width and height to image() as options * incorporated feedback * Update src/fileAttachment.js Co-authored-by: Mike Bostock <[email protected]> * using setAttribute instead of constructor * added alt and title * added style * changing to pass through all props * moving props to after crossOrigin assignment Co-authored-by: Mike Bostock <[email protected]>
1 parent b9bbd5c commit fdd8226

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/fileAttachment.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,14 @@ export class AbstractFile {
4242
async tsv(options) {
4343
return dsv(this, "\t", options);
4444
}
45-
async image() {
45+
async image(props) {
4646
const url = await this.url();
4747
return new Promise((resolve, reject) => {
48-
const i = new Image;
48+
const i = new Image();
4949
if (new URL(url, document.baseURI).origin !== new URL(location).origin) {
5050
i.crossOrigin = "anonymous";
5151
}
52+
Object.assign(i, props);
5253
i.onload = () => resolve(i);
5354
i.onerror = () => reject(new Error(`Unable to load file: ${this.name}`));
5455
i.src = url;

0 commit comments

Comments
 (0)