Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
project
soundcloudfield
Commits
2f4b2cc8
Commit
2f4b2cc8
authored
Feb 19, 2021
by
vinmassaro
Browse files
Issue
#3199360
: Soundcloud oEmbed endpoint now defaulting to JSON response, breaks embeds
parent
42ed9e46
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/Plugin/Field/FieldFormatter/SoundCloudDefaultFormatter.php
View file @
2f4b2cc8
...
...
@@ -2,6 +2,7 @@
namespace
Drupal\soundcloudfield\Plugin\Field\FieldFormatter
;
use
Drupal\Component\Serialization\Json
;
use
Drupal\Core\Field\FieldItemListInterface
;
use
Drupal\Core\Field\FormatterBase
;
use
Drupal\Core\Form\FormStateInterface
;
...
...
@@ -205,12 +206,12 @@ class SoundCloudDefaultFormatter extends FormatterBase {
if
(
$soundcloud_curl_get
!=
' '
)
{
// Load in the oEmbed XML.
$oembed
=
simplexml_load_string
(
$soundcloud_curl_get
);
$oembed
=
Json
::
decode
(
$soundcloud_curl_get
);
// Replace player default settings with our settings,
// set player width and height first.
$final_iframe
=
preg_replace
(
'/(width=)"([^"]+)"/'
,
'width="'
.
$width
.
'%"'
,
$oembed
->
html
);
$final_iframe
=
preg_replace
(
'/(height=)"([^"]+)"/'
,
'height="'
.
$iframe_height
.
'"'
,
$oembed
->
html
);
$final_iframe
=
preg_replace
(
'/(width=)"([^"]+)"/'
,
'width="'
.
$width
.
'%"'
,
$oembed
[
'
html
'
]
);
$final_iframe
=
preg_replace
(
'/(height=)"([^"]+)"/'
,
'height="'
.
$iframe_height
.
'"'
,
$oembed
[
'
html
'
]
);
// Set autoplay.
if
(
preg_match
(
'/auto_play=(true|false)/'
,
$final_iframe
))
{
$final_iframe
=
preg_replace
(
'/auto_play=(true|false)/'
,
'auto_play='
.
$autoplay
,
$final_iframe
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment