When I check the box for "Strip html", I'm seeing some output from one of my videos inserted using the Media and media_youtube module.

Here is a sample of what is displayed in the teaser:
This is some test content. This is some test content. Video of Cat Man Do - Simon's Cat Here is a test Here is another list item Here is another list item Design to theme Here is some highlighted text This is a paragraph that flows around an image. This is a paragraph that...

The media module inserts code like:
<p>[[{"fid":"110","view_mode":"4_x_3_video","type":"media","attributes":{"height":360,"width":480,"alt":"Cat Man Do - Simon's Cat","class":"media-element file-4-x-3-video"}}]]</p>

Notice the "Video of Cat Man Do - Simon's Cat?" I would think that whole phrase should be stripped out since it is just a youtube video that was inserted using the media module.

Any ideas on how I can fix this?

Comments

chrisjlee’s picture

Status: Active » Postponed

Media module is not integrated at the moment and probably won't be considered at the moment. Otherwise i think your best bet at the moment would be to write a custom formatter for your case.

Regardless, patches are welcome.

damienmckenna’s picture

Title: Strip HTML and Media module » Strip Media module code
Version: 7.x-1.4 » 7.x-1.x-dev
Category: Bug report » Feature request
Issue summary: View changes

Support for the Media module's embedded code is a feature request.

frankcarey’s picture

Any reason not to strip things AFTER all the input formats have processed any tokens or related items? (I assume the module stores or caches the results?)

Andreas Radloff’s picture

Status: Postponed » Needs review
StatusFileSize
new1.94 KB

How about this patch? Added option to strip media tags.

Andreas Radloff’s picture

@frankcarey the reason is that the caption text field that the media module inserts does not count as html and as such remains after the html has been stripped. Therefore you must strip media tokens before they are converted to markup.

mkhamash’s picture

StatusFileSize
new1.94 KB

Re-roll for the patch., wrong patch file see the one in the next comment.

mkhamash’s picture

StatusFileSize
new1.99 KB

Ow that is the same old one, here is the reroll.

rrrob’s picture

StatusFileSize
new1.96 KB

Rerolled and cleaned up.

dww’s picture

Title: Strip Media module code » Add option to strip Media module code
Status: Needs review » Reviewed & tested by the community

I ran into the same problem, and patch #8 is working nicely to solve it. Applies cleanly to the end of the 7.x-1.x branch. Adheres to coding standards. Works well on my test sites. Doesn't introduce any obvious problems (at least to my eyes). ;) Doesn't need a migration path, since it's just a new checkbox option. RTBC! :)

Thanks,
-Derek

mkhamash’s picture

I have been using this patch for quite a long time now on multiple projects, I think it is safe to commit it.

didebru’s picture

Not working for me :(
I have updated to latest dev.
As I implemented the patch I got this :

patch -p1 < smart_trim-strip_media_tokens-2041053-8.patch 
patching file smart_trim.module
Hunk #1 FAILED at 42.
Hunk #2 succeeded at 246 (offset 9 lines).
1 out of 2 hunks FAILED -- saving rejects to file smart_trim.module.rej

Than I did it manually but when I check the new option nothing happens.....

markie’s picture

Status: Reviewed & tested by the community » Needs work

Patch #8 needs re-rolling. Thanks

gmclelland’s picture

FYI.. There is a similar issue in the media module queue.

#2165457: Create text filter "Remove media tags"

omerida’s picture

Here's a re-rolled version of #8 which applied for me:

markie’s picture

@omerida patch is relative to root, (/html/sites/all/modules/contrib/smart_trim/smart_trim.module) and should be ran from the smart_trim folder.

jonraedeke’s picture

Status: Needs work » Needs review
StatusFileSize
new1.73 KB

Rerolled to work with latest dev.

This feature request is really useful, especially when using smart trim for Metatag tokens.

markie’s picture

StatusFileSize
new530 bytes

All
I went a different direction with this. I figure the media code and all tokens are part of the HTML that needs to be counted, so I added a `token_replace` before the word counts which formats the media tokens into HTML and then it is part of the count with the HTML instead of the token code. Please see attached patch.

anybody’s picture

Also see #3301743: Support tokens in more text and replace in content before trimming (Drupal 8+) which is closely related and could benefit from #17's approach!

Anyway, I guess token_replace() needs a check if the token module is enabled?

If #17 works correctly, I think that would be the best solution, but would need an IF around it to check if token module is enabled.

markie’s picture

Status: Needs review » Closed (outdated)

Drupal 7 is EOL. If this applies to 2.x please reopen and update to that branch.