I'm using node_embed to embed nodes into the body of my main content type. This works fine but whenever I save a node with embedded nodes within its body I get the notice Unable to render media from nid:******. Error: No file Id. Apparently this is a generic notice generated by /sites/all/modules/contrib/media/modules/media_wysiwyg/includes/media_wysiwyg.filter.inc but it doesn't represent the reality as I'm not really embedding media.

I've upgraded to the latest version of node_embed and WYSIWYG and this still happens. From the external documentation of node_embed:

Using Node Embed and Media tags

The WYSIWG integration of Media breaks the Insert Node input filter and removes its content, because the Media tags are using a simular filter tag format as Node embed. To avoid problems you need to process the Insert Node input filter before the Convert Media tags to Markup input filter.

While this is not exactly the issue I'm experiencing, I understand that this issue has to do with the similarity of the WYSIWYG embed formats between node_embed ([[*]]) and Media module ([[{*}]]).
Note: I'm not even using the Convert Media tags to markup filter under /admin/config/content/formats/my_format.

Any ideas on how I can keep my dblog clear from these notices every time I save a node?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

weborion created an issue. See original summary.

ioanmar’s picture

Issue summary: View changes
ioanmar’s picture

I'm adding a negative lookahead to the regex to make sure the intended media embed token is not coming from other possible modules such as node_embed.

ioanmar’s picture

Status: Active » Needs review
joseph.olstad’s picture

Your configuration is incorrect however I'm unfamiliar with the node_embed module , it is possible that we could improve integration with that.

For an optimal configuration, please refer to the media recipe and the instructions in the recipe.

The media recipe is a make file , you can copy it into a file and run drush make, drush make will download the drupal core for you, contrib modules and libraries.
From there, follow the instructions in the make file and troubleshooting tips in there and if you need more info refer to the recipe page and look at the feedback.

For a more radical configuration, if you want to really go all out, I've cooked up a radical make file here in my sandbox , its got a lot of performance patches to contrib modules, many extra libraries and is pretty insane.

The make file requires at least drush version 6 or 7 I think. I'm using 7.4.x . It won't work on drush 5.x.

joseph.olstad’s picture

If you don't want to run the make file for some reason, the information in the recipe has the information you need in order to properly configure media

joseph.olstad’s picture

Category: Bug report » Support request
ioanmar’s picture

What part of my configuration is incorrect?

I'm happy to follow a recipe but existing configurations don't necessarily follow the same recipe.

The patch simply helps media_wysiwyg ignore embedded node tags, otherwise it generates a (false, in this case) notice (as mentioned above, node_embed adds tags in the format [[nid:****]]).

joseph.olstad’s picture

# 2. Enable these modules:
# - media_ckeditor
# - token
# - media_oembed
# 3. At /admin/config/content/ckeditor/editg change the value for
# "Path to the CKEditor plugins directory" to: %l/ckeditor/plugins
# 4. Go to a text format edit page (such as /admin/config/content/formats/my_format),
# then make sure this checkbox is checked:
# - "Convert Media tags to markup"
# make sure that - "Convert URLs into links" is at the bottom, or else disabled.
# If you do not have these ordered correct Drupal will render codes instead of images.
# 5. Go to the CKEditor profile edit page for the text format (such as
# /admin/config/content/ckeditor/edit/MyFormat) and make sure these
# checkboxes are checked under the "Editor Appearance" section:
# - "Plugin for embedding files using Media CKEditor"
# - "Plugin file: lineutils"
# - "Plugin file: widget"
# - "Plugin file: widgetselection"
# 6. Set your MyFormat as the default text format:
# - go to /admin/config/content/formats drag your MyFormat to the top
# - click save
# 7. Disable the ACF in the "Advanced Content Filter" section

# Troubleshooting:

# Filter processing order
# 1. (Optional) Ensure that embedded Media tags are not contained in paragraphs
# 2. Convert Media tags to markup
# 3. (Optional) Correct faulty and chopped off HTML
# when troubleshooting, disable the other 'Filters'  
# admin/config/content/formats, making sure that the 'media' ones are enabled
joseph.olstad’s picture

if you're using the wysiwyg module with Tiny_MCE instead of ckeditor module or using the ckeditor library with the wysiwig module , the configuration is similar but not exact.

the order of the plugins is important and the filter processing order is important .

ioanmar’s picture

I'm not using Tiny_MCE. The configuration in your last comment can possibly be more helpful for new builds - and thanks for taking the time to compile that list - but it's still an overkill to apply all these changes for complex, existing installations.

The issue I'm facing is much simpler than that and the patch is mostly recipe - agnostic, apart from the existence of node_embed itselft of course.
From node embed doc:

Using Node Embed and Media tags

Othert users have reported similar problems and node_embed maintainers know about the issue too:
The WYSIWG integration of Media breaks the Insert Node input filter and removes its content, because the Media tags are using a simular filter tag format as Node embed. To avoid problems you need to process the Insert Node input filter before the Convert Media tags to Markup input filter.

I'm having this issue while still respecting the order of the filters and trying many other possible combinations.

Under these circumstances, doesn't this patch provide a simple fix for the issue?

joseph.olstad’s picture

Have you reviewed the filter processing order?

To avoid problems you need to process the Insert Node input filter before the Convert Media tags to Markup input filter.

So respect the Node Embed configuration, but also the nuances of the Media configuration.

# Filter processing order
# 1. (Optional) Ensure that embedded Media tags are not contained in paragraphs
# 2. Convert Media tags to markup
# 3. (Optional) Correct faulty and chopped off HTML

# when troubleshooting, disable the other 'Filters'

Try enabling 'Node Embed' after you've confirmed Media is working. Once you've confirmed Media as working then
put Node Embed processing at number 2 and Convert Media tags to markup is ordered at number 3, bump Correct faulty and chopped off HTML to number 4

We might consider committing your patch if it is confirmed to NOT break Media, be sure to back off your patch and try to get it working without your patch first. Are we absolutely sure a patch is needed? Will it break other configurations?

review the rest of the config, try to get it working without a patch first.

It could be that your patch is required , however this part of the code is the crux of the whole embed processing so it's going to have to work for everyone, not just those using Node embed.

joseph.olstad’s picture

ok, ya I had another look at your patch, it probably won't break media.

Were you able to get this working without the patch? or is this the >ONLY< way?

the regex however does look like it makes sense, stops processing when it finds 'nid'
Media doesn't use 'nid' so without even testing it, probably safe to say that it won't break something..

  • weborion authored 175e50a on 7.x-3.x
    Issue #2894830 by weborion: Unable to render media from nid:******....

  • weborion authored 72a863d on 7.x-2.x
    Issue #2894830 by weborion: Unable to render media from nid:******....
joseph.olstad’s picture

Category: Support request » Bug report
Status: Needs review » Fixed

ok ya, looks good. Leaving this in dev for a bit. Tag a release some time next month in september.

ioanmar’s picture

Yes, I've tested numerous configurations on my build and this issue always happens when node_embed and media_wysiwyg are on at the same time.

Indeed, we shouldn't be worried about it breaking media as the only thing it checks for is the nid: bit in the embed tag which, as you mention, media doesn't use at all.

Thanks for looking into that.

joseph.olstad’s picture

Thanks for your patience, and for reporting and fixing the issue!

great work

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.