Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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 |
|
Comments
Comment #2
sasanikolic CreditAttribution: sasanikolic at MD Systems GmbH commentedComment #3
sasanikolic CreditAttribution: sasanikolic at MD Systems GmbH commentedHere is the patch with the proposed solution.
Comment #4
sasanikolic CreditAttribution: sasanikolic at MD Systems GmbH commentedI think we should also call init when twttr is defined.