-1

I am trying to create a simple paragraph type that contains a entity reference field for media. The way it should work is that the user should be able to type in the image or the video that they would like to display and then from there I would use a preprocess hook to get ahold of the information I need.

I can get it to work with images but I am having issues with getting it to to work with local video files and embedded videos.

Preprocessor Hook

case 'media_panel':
      echo "<div style='height: 400px'></div>";
      $media_id = $p->field_media->target_id;
      $media_file = file_load($media_id);
      $media_public_uri = $media_file->getFileUri();
      $x = file_create_url($media_public_uri);

      $section[$key]['media_panel'] = [
        '#media' => $x,
      ];
      break;

Landing Page Template Twig

{% if key == "media_panel" %}
              <iframe src="{{ item["#media"] }}" width="100%" height="100%"></iframe>

{% endif %}

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.