Skip to content

Commit

Permalink
Merge pull request #4 from intuiface/hotfix/InvalidImageSource
Browse files Browse the repository at this point in the history
revert: avoid creating an empty image if loading fail, use imagePlaceholder instead
  • Loading branch information
mikaelkurek authored Feb 29, 2024
2 parents de158fd + 6a64bb7 commit 11fd7c2
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 14 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## [1.11.18](https://github.com/bubkoo/html-to-image/compare/v1.11.17...v1.11.18) (2024-02-28)

### Bug Fixes

* revert all commits which use an empty image as the option imagePlaceholder can be used

## [1.11.17](https://github.com/bubkoo/html-to-image/compare/v1.11.16...v1.11.17) (2024-02-26)

### Bug Fixes
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@intuiface/html-to-image",
"version": "1.11.17",
"version": "1.11.18",
"description": "Generates an image from a DOM node using HTML5 canvas and SVG. This is a fork from antoher fork Repo (2knu/html-to-image) from the original Repo (bubkoo/html-to-image)",
"main": "lib/index.js",
"module": "es/index.js",
Expand Down
6 changes: 0 additions & 6 deletions src/clone-node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,6 @@ async function cloneVideoElement(video: HTMLVideoElement, options: Options) {
const dataURL = canvas.toDataURL()
return createImage(dataURL)
}
if (video.poster == null || video.poster === '') {
// create an image with the tyniest source found
return createImage(
'data:image/png;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==',
)
}

const poster = video.poster
const contentType = getMimeType(poster)
Expand Down
6 changes: 1 addition & 5 deletions src/embed-images.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,7 @@ async function embedImageNode<T extends HTMLElement | SVGImageElement>(
return
}

let url = isImageElement ? clonedNode.src : clonedNode.href.baseVal
if (!url || url === '') {
url =
'data:image/png;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=='
}
const url = isImageElement ? clonedNode.src : clonedNode.href.baseVal

const dataURL = await resourceToDataURL(url, getMimeType(url), options)
await new Promise((resolve, reject) => {
Expand Down

0 comments on commit 11fd7c2

Please sign in to comment.