1

I have a formatted text field, and am using the video_embed module to allow users to embed video into that field, using the video_embed_wysiwyg submodule.

I am then trying to render the field in a block, but I simply get the JSON output in the text field:

{"preview_thumbnail":"/sites/default/files/styles/video_embed_wysiwyg_preview/public/video_thumbnails/A5jNGsBHHUE.jpg?itok=7fW8O9To","video_url":"https://www.youtube.com/watch?v=********","settings":{"responsive":1,"width":"854","height":"480","autoplay":1},"settings_summary":["Embedded Video (Responsive, autoplaying)."]}

Here is my render array:

$text=check_markup($node->get('field_html_containing_video_content')->value, $node->get('field_html_containing_video_content')->format);

    $renderArray=[
      'content'=>[
        '#type'=>'inline_template',
        '#template'=>$text
      ]
    ];

    return $renderArray; 

I've got the video embed filter enabled on the relevant text format, and have tried changing the order of the filters.

Any ideas what i am doing wrong here?

We are using a bootstrap subtheme.

Thanks for any help given.

1 Answer 1

3

check_markup() is not able to handle attached metadata which some text filters need to work properly.

You have to use the render element processed_text:

$renderArray = [
  'content' => [
    '#type' => 'processed_text',
    '#text' => $node->field_html_containing_video_content->value,
    '#format' => $node->field_html_containing_video_content->format,
  ],
];

More info How to safely render node body on a custom variable?

1
  • Thanks 4k4 - much aprpeciated (and sorry for the slow answer acceptance and reply)
    – gillarf
    Sep 4, 2020 at 15:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.