문제

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.

도움이 되었습니까?

해결책

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?

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 drupal.stackexchange
scroll top