{"author_link":"\/users\/aa4z2","author_name":"aa4z2","author_uid":"aa4z2","comments":[],"epoch":1671996894,"event":"LD52","format":"md","ldjam_node_id":313851,"likes":7,"metadata":{"p_key":"169731","p_author":"aa4z2","p_authorkey":"1123249","p_urlkey":"397651","p_title":"Note to Phaser users - images in embedded games don't load","p_cat":"LDJam ","p_event":"LD52","p_time":"1671996894","p_likes":"7","p_comments":"0","p_status":"WAYBACK","us_key":"1123249","us_name":"aa4z2","us_username":"aa4z2","event_start":"1672963200","event_key":"116","event_name":"Ludum Dare 52"},"node":{"_collation":{"body_sanitizer":"TextUtils::SanitizeHTML via existing importer","event":"LD52","removed_author":false},"_superparent":313060,"_trust":3,"author":123249,"body":"Currently, games made with [Phaser](https:\/\/phaser.io\/) engine don't work when [embedded](https:\/\/ludumdare.com\/resources\/guides\/embedding\/) in the game page (specifically, images won't load). But - there is a workaround.\n\n# What to do\nIf you build a game using Phaser, go to the phaser.js file (the one huge file that contains the whole engine), look for the following around line 5070:\n```\nif (typeof URL === 'function')\n```\nand change it into\n```\nif (false)\n```\nIf you use the minified version of the engine (phaser.min.js), change instead\n```\n\"function\"==typeof URL?t.src=URL.createObjectURL\n```\ninto\n```\nfalse?t.src=URL.createObjectURL\n```\n(this one wasn't tested)\n\n# Why it works\nThe content security policy (CSP) for embedded games contains the directive `default-src 'self' data:`, which allows game engines to show images using data: URLs, but not the more modern blob: URLs. The default in Phaser is to use blob: URLs, the changes above force it to use the data: fallback.\n\nThis took us a few hours to figure during LD51, hope it will help others.\n\n\n@pov, can you add \"blob:\" to the CSP? If not, can you add this tip to the game embedding guide? I believe that this is where people will look if they have this problem.","comments":1,"comments-timestamp":"2022-12-26T03:40:47Z","created":"2022-12-25T19:28:57Z","files":[],"files-timestamp":0,"id":313851,"love":7,"love-timestamp":"2022-12-26T16:01:45Z","meta":[],"modified":"2022-12-26T16:01:45Z","name":"Note to Phaser users - images in embedded games don't load","node-timestamp":"2022-12-25T19:34:54Z","parent":313850,"parents":[1,5,9,313060,313850],"path":"\/events\/ludum-dare\/52\/$313850\/note-to-phaser-users-images-in-embedded-games-dont-load","published":"2022-12-25T19:34:54Z","scope":"public","slug":"note-to-phaser-users-images-in-embedded-games-dont-load","subsubtype":"","subtype":"","type":"post","version":976422},"node_metadata":{"n_key":"313851","n_urlkey":"397651","n_parent":"313850","n_path":"\/events\/ludum-dare\/52\/$313850\/note-to-phaser-users-images-in-embedded-games-dont-load","n_slug":"note-to-phaser-users-images-in-e","n_type":"post","n_subtype":"","n_subsubtype":"","n_author":"123249","n_created":"1671996537","n_modified":"1672070505","n_version":"976422","n_status":"WAYBACK"},"source_url":"https:\/\/ldjam.com\/events\/ludum-dare\/52\/$313850\/note-to-phaser-users-images-in-embedded-games-dont-load","text":"Currently, games made with [Phaser](https:\/\/phaser.io\/) engine don't work when [embedded](https:\/\/ludumdare.com\/resources\/guides\/embedding\/) in the game page (specifically, images won't load). But - there is a workaround.\n\n# What to do\nIf you build a game using Phaser, go to the phaser.js file (the one huge file that contains the whole engine), look for the following around line 5070:\n```\nif (typeof URL === 'function')\n```\nand change it into\n```\nif (false)\n```\nIf you use the minified version of the engine (phaser.min.js), change instead\n```\n\"function\"==typeof URL?t.src=URL.createObjectURL\n```\ninto\n```\nfalse?t.src=URL.createObjectURL\n```\n(this one wasn't tested)\n\n# Why it works\nThe content security policy (CSP) for embedded games contains the directive `default-src 'self' data:`, which allows game engines to show images using data: URLs, but not the more modern blob: URLs. The default in Phaser is to use blob: URLs, the changes above force it to use the data: fallback.\n\nThis took us a few hours to figure during LD51, hope it will help others.\n\n\n@pov, can you add \"blob:\" to the CSP? If not, can you add this tip to the game embedding guide? I believe that this is where people will look if they have this problem.","title":"Note to Phaser users - images in embedded games don't load","wayback_source":[]}