Commit 2f4b2cc8 authored by vinmassaro's avatar vinmassaro
Browse files

Issue #3199360: Soundcloud oEmbed endpoint now defaulting to JSON response, breaks embeds

parent 42ed9e46
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
namespace Drupal\soundcloudfield\Plugin\Field\FieldFormatter; namespace Drupal\soundcloudfield\Plugin\Field\FieldFormatter;
use Drupal\Component\Serialization\Json;
use Drupal\Core\Field\FieldItemListInterface; use Drupal\Core\Field\FieldItemListInterface;
use Drupal\Core\Field\FormatterBase; use Drupal\Core\Field\FormatterBase;
use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Form\FormStateInterface;
...@@ -205,12 +206,12 @@ class SoundCloudDefaultFormatter extends FormatterBase { ...@@ -205,12 +206,12 @@ class SoundCloudDefaultFormatter extends FormatterBase {
if ($soundcloud_curl_get != ' ') { if ($soundcloud_curl_get != ' ') {
// Load in the oEmbed XML. // 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, // Replace player default settings with our settings,
// set player width and height first. // set player width and height first.
$final_iframe = preg_replace('/(width=)"([^"]+)"/', 'width="' . $width . '%"', $oembed->html); $final_iframe = preg_replace('/(width=)"([^"]+)"/', 'width="' . $width . '%"', $oembed['html']);
$final_iframe = preg_replace('/(height=)"([^"]+)"/', 'height="' . $iframe_height . '"', $oembed->html); $final_iframe = preg_replace('/(height=)"([^"]+)"/', 'height="' . $iframe_height . '"', $oembed['html']);
// Set autoplay. // Set autoplay.
if (preg_match('/auto_play=(true|false)/', $final_iframe)) { if (preg_match('/auto_play=(true|false)/', $final_iframe)) {
$final_iframe = preg_replace('/auto_play=(true|false)/', 'auto_play=' . $autoplay, $final_iframe); $final_iframe = preg_replace('/auto_play=(true|false)/', 'auto_play=' . $autoplay, $final_iframe);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment