Problem/Motivation

I have many blog posts that include video embeds at the top, that I want to appear in the trimmed version. Other types of media (documents, images) do appear within the trimmed post, but video content (both local and remote) just gets skipped over, but text from after the video does show up in the trimmed version.

I would expect that the video(s) would appear in the trimmed / Teaser if the text after appears in it.

Using Drupal 10.2.3 on Apache webserver, PHP 8.2.16.

Steps to reproduce

  1. Select a content type that has a body filed type "Text (formatted, long, with summary)" and create a new node
  2. Embed a video near the top of the new node body, remote or local or both.
  3. Add some text after the video(s) and save.
  4. Look at the Teaser view -- e.g. in a View or Teaser preview. The video content will have been removed but the text after it may be in the Teaser, depending on how many characters the trimmed limit is set to.

Remote video like this is removed:

<drupal-media data-entity-type="media" data-entity-uuid="c88d434d-9776-4635-80e9-4747746e4336">&nbsp;</drupal-media>

And local video like this is also removed:

<drupal-media data-entity-type="media" data-entity-uuid="920e4c52-ff87-4607-95e8-c9cd5fdca44b">&nbsp;</drupal-media>

Oddly, the trimmed HTML includes this wrapper around the missing videos (remote first, then local):

<div>
            <div class="field field--name-field-media-oembed-video field--type-string field--label-hidden field--item">
</div>
</div>
<div>
  
  
  <div class="field field--name-field-media-video-file-1 field--type-file field--label-visually_hidden">
    <div class="field--label sr-only">Video file</div>
              <div class="field--item">
      
  
</div>
          </div>

</div>

@ressa confirms the issue at https://www.drupal.org/forum/support/post-installation/2024-02-27/choose...

Proposed resolution

Expected behavior: Video media elements that are included in the body should appear in the Teaser / trimmed output, subject to the trimmed length limit.

Comments

leeksoup created an issue. See original summary.

cilefen’s picture

Component: filter.module » text.module

This occurs in the text_summary function in the text module. It depends on a format passed to it so I would look at its callers. I haven't done a deep look but this may be the intended behavior rather than a bug, although of course it could be changed. Or, it's a bug.

pameeela’s picture

Version: 10.2.x-dev » 11.x-dev
Issue tags: +Bug Smash Initiative

Confirmed this occurs but interestingly the video remains if you use the Smart trim formatter.

leeksoup’s picture

@pameeela - Somehow I overlooked your post earlier. Is the Smart trim formatter you linked a drop-in replacement for the default one?

pameeela’s picture

@leeksoup yes, it works well and also strips HTML tags when calculating the trimming.

cilefen’s picture

Status: Active » Postponed (maintainer needs more info)

There is a clear solution then. Can we close this?

pameeela’s picture

Status: Postponed (maintainer needs more info) » Active

I guess it could be converted to a feature request for adding support to core, or closed since it's nicely solved in contrib.

pameeela’s picture

Category: Bug report » Feature request
Status: Active » Postponed (maintainer needs more info)
Related issues: +#3473241: Strip tags from formatted text before trimming

Oops, didn't mean to change status.

pameeela’s picture

Title: all video embeds are removed from Teasers » All video embeds are removed from teasers
leeksoup’s picture

@pameeela - thanks.

@cilefen - I will test and check whether the contrib module works for me, and report back.

leeksoup’s picture

@cilefen, @pameeela - Yes, the Smart Trim module works for me and resolves both this issue and the related one to strip tags before counting characters for text trimming.

I agree with making it a feature request. Thanks.

smustgrave’s picture

Bumping once to see if this should be closed?

leeksoup’s picture

@smustgrave - I have a solution for this issue and this page documents it. Even though I still think the core function isn't handling this correctly, I have a great workaround, so it can be closed as far as I'm concerned. Thanks.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.

smustgrave’s picture

Status: Postponed (maintainer needs more info) » Closed (outdated)

Thanks! Since it was a feature request and been a while I will close out. Am assigning credit though for the discussion

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.