Add support for poster image

Created on 11 August 2016, almost 9 years ago
Updated 9 August 2023, almost 2 years ago

Hi All, I'm working with Drupal8 and am trying to add a poster image based off the instructions in the Read Me. However, when I click on the config for the VideoJS field I don't see any option to reference my Image field for the poster. Has anyone got this Video Poster functionality to work?

I was able to modify some of the files in order to get it working with a text field, but it isn't ideal:

VideoJsPLayerFormatter.php added this block in the settingsForm function...

$element['poster'] = [
'#title' => t('Poster (Thumbnail)'),
'#type' => 'textfield',
'#default_value' => $this->getSetting('poster'),
'#required' => FALSE,
];

Added this line in the videojs.html.twig...

poster="{{ player_attributes.poster }}" {{ player_attributes.poster ? 'poster' : '' }}

Thanks in advance.

Feature request
Status

Needs review

Version

1.0

Component

Code

Created by

🇺🇸United States tom_nguyen

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇺🇸United States damienmckenna NH, USA

    One problem here is that there's an assumption on which field name should be used; should it be configurable or something? The main differences between #13 and #19 are in the image field name - #13 uses field_image whereas #19 uses field_media_image.

    FWIW we've been using #13 on a production site for a few years.

  • 🇺🇦Ukraine _shy Ukraine, Lutsk 🇺🇦

    Please, reroll the patch to the latest branch version.

  • Status changed to Needs work over 1 year ago
  • 🇺🇦Ukraine _shy Ukraine, Lutsk 🇺🇦
  • 🇺🇸United States wstocker

    Patch re-rolled and updated with Drupal core 9.5.x.

  • 🇮🇳India sakthi_dev

    The patch provided in #24 not patching the files correctly instead it's creating a patch file inside the directory. As per comment #22 added Needs Reroll to the tags.

  • 🇺🇸United States wstocker

    @sakthi_dev Whoops apologies wrong file. Here is the updated one.

  • Status changed to Needs review over 1 year ago
  • 🇺🇸United States damienmckenna NH, USA
  • 🇺🇸United States wstocker

    Patch 26 applied, but to Damiens' point there were PHP errors surrounding the new field name in #20.

    We had been using patch #13 for several years which has field_image instead of field_media_image.

    I think making that configurable is a good idea, but for now, I re-rolled and created patch #28 using patch #13 to start and the errors disappeared.

    Patch applies clean to 8.x-1.x.

  • 🇺🇸United States wstocker

    Patch #28 is incompatible with D10 as it uses deprecated and removed file_create_url().
    Refactored so it is compatible with D10 and 3.x.

  • wstocker, patch #29 doesn't work for me.
    Drupal 10.2.8.
    Videojs 3.x.

    When I aplied the patch I got the next error:

    InvalidArgumentException: Field is unknown. in Drupal\Core\Entity\ContentEntityBase->getTranslatedField() (line 616 of core\lib\Drupal\Core\Entity\ContentEntityBase.php)
    
    Drupal\Core\Entity\ContentEntityBase->get() (Line: 146)
    Drupal\videojs\Plugin\Field\FieldFormatter\VideoJsPlayerListFormatter->viewElements() (Line: 91)
    Drupal\Core\Field\FormatterBase->view() (Line: 76)
    Drupal\Core\Field\Plugin\Field\FieldFormatter\EntityReferenceFormatterBase->view() (Line: 268)
    Drupal\Core\Entity\Entity\EntityViewDisplay->buildMultiple() (Line: 339)
    Drupal\Core\Entity\EntityViewBuilder->buildComponents() (Line: 24)
    Drupal\node\NodeViewBuilder->buildComponents() (Line: 281)
    Drupal\Core\Entity\EntityViewBuilder->buildMultiple() (Line: 238)
    Drupal\Core\Entity\EntityViewBuilder->build()
    call_user_func_array() (Line: 111)
    Drupal\Core\Render\Renderer->doTrustedCallback() (Line: 859)
    Drupal\Core\Render\Renderer->doCallback() (Line: 421)
    Drupal\Core\Render\Renderer->doRender() (Line: 240)
    Drupal\Core\Render\Renderer->render() (Line: 238)
    Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}() (Line: 627)
    Drupal\Core\Render\Renderer->executeInRenderContext() (Line: 239)
    Drupal\Core\Render\MainContent\HtmlRenderer->prepare() (Line: 128)
    Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse() (Line: 90)
    Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray()
    call_user_func() (Line: 111)
    Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch() (Line: 186)
    Symfony\Component\HttpKernel\HttpKernel->handleRaw() (Line: 76)
    Symfony\Component\HttpKernel\HttpKernel->handle() (Line: 58)
    Drupal\Core\StackMiddleware\Session->handle() (Line: 48)
    Drupal\Core\StackMiddleware\KernelPreHandle->handle() (Line: 28)
    Drupal\Core\StackMiddleware\ContentLength->handle() (Line: 32)
    Drupal\big_pipe\StackMiddleware\ContentLength->handle() (Line: 106)
    Drupal\page_cache\StackMiddleware\PageCache->pass() (Line: 85)
    Drupal\page_cache\StackMiddleware\PageCache->handle() (Line: 48)
    Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle() (Line: 51)
    Drupal\Core\StackMiddleware\NegotiationMiddleware->handle() (Line: 36)
    Drupal\Core\StackMiddleware\AjaxPageState->handle() (Line: 51)
    Drupal\Core\StackMiddleware\StackedHttpKernel->handle() (Line: 704)
    Drupal\Core\DrupalKernel->handle() (Line: 19)
    
Production build 0.71.5 2024