Skip to content

Commit ab675cd

Browse files
authored
Merge pull request #4104 from stalgiag/warningForNoHeaders
Safer content-type checking and warning for images with no header.
2 parents a7a1b10 + bac9d8a commit ab675cd

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/image/loading_displaying.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,13 @@ p5.prototype.loadImage = function(path, successCallback, failureCallback) {
7474

7575
fetch(path, req).then(response => {
7676
// GIF section
77-
if (response.headers.get('content-type').includes('image/gif')) {
77+
const contentType = response.headers.get('content-type');
78+
if (contentType === null) {
79+
console.warn(
80+
'The image you loaded does not have a Content-Type header. If you are using the online editor consider reuploading the asset.'
81+
);
82+
}
83+
if (contentType && contentType.includes('image/gif')) {
7884
response.arrayBuffer().then(
7985
arrayBuffer => {
8086
if (arrayBuffer) {

0 commit comments

Comments
 (0)