Problem
I noticed this issue when using an entity browser to display media bundles. One of them is a twitter media entity. The twitter widget gets loaded as it should, but we get a few errors in the console saying twttr is not defined.
Proposed solution
The issue is in the twitter.js file, where we check if twttr is not defined and load it from the //platform.twitter.com/widgets.js instead, but we have no guarantee that this file gets loaded before the init function gets called. Therefore, we need to call the init function in a callback (e.g. on script load: https://javascript.info/onload-onerror).
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | 3159873-twttr-not-defined-4-interdiff.txt | 228 bytes | sasanikolic |
| #4 | 3159873-twttr-not-defined-4.patch | 507 bytes | sasanikolic |
| #3 | 3159873-twttr-not-defined.patch | 466 bytes | sasanikolic |
Issue fork media_entity_twitter-3159873
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
sasanikolic commentedComment #3
sasanikolic commentedHere is the patch with the proposed solution.
Comment #4
sasanikolic commentedI think we should also call init when twttr is defined.
Comment #7
liam morlandI have created a merge request with the patch in #4.