Skip to content

Commit 39c6997

Browse files
author
Lauren McCarthy
committed
fixes #1741
1 parent 47f642a commit 39c6997

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/image/loading_displaying.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,8 +216,16 @@ p5.prototype.image =
216216
_sw = _sAssign(_sw, defW);
217217
_sh = _sAssign(_sh, defH);
218218

219+
220+
// This part needs cleanup and unit tests
221+
// see issues https://github.com/processing/p5.js/issues/1741
222+
// and https://github.com/processing/p5.js/issues/1673
219223
var pd = 1;
220-
if (img.elt && img.elt.width && img.elt.style.width) {
224+
225+
if (img.elt && img.elt.videoWidth && img.elt.style.width && !img.canvas) {
226+
pd = img.elt.videoWidth / parseInt(img.elt.style.width, 10);
227+
}
228+
else if (img.elt && img.elt.width && img.elt.style.width) {
221229
pd = img.elt.width / parseInt(img.elt.style.width, 10);
222230
}
223231

0 commit comments

Comments
 (0)