Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Drupal - Custom theme does not parse media module markup

I've got a problem with Media module for Drupal 7, it works great all over the site, except in a custom module I've created. The field that is used by this module, uses the same text formatting as rest of site, it properly renders bolds, tables, all TinyMCE things. But somehow it can't handle images inserted by media plugin.

If I add ordinary article content type, then it works ok. Only fields rendered by my module are not parsed.

So - I display a field by:

   echo '<p class="product-section-content">' . $element['value'] . '</p>'."\n";

but, instead of image I get:

[[{"type":"media","view_mode":"media_large","fid":"71","attributes":{"alt":"","class":"media-image","typeof":"foaf:Image"}}]][[{"type":"media","view_mode":"media_large","fid":"63","attributes":{"alt":"","class":"media-image","typeof":"foaf:Image"}}]] 

What should I call, to parse this markup tags?

like image 688
Atomicus Avatar asked Jun 20 '26 14:06

Atomicus


2 Answers

It's because the Media module provides a new input filter that's not activated by default. This filter is required to parse the media tags.

You need to go to admin/config/content/formats, edit the text format(s) you want to use with media, and enable the Converts Media tags to Markup checkbox for each.

Then it'll work :)

like image 129
Clive Avatar answered Jun 22 '26 12:06

Clive


For Media module (1.x branch only) you can normally use the media_filter function:

print media_filter(html);
like image 24
solvease Avatar answered Jun 22 '26 10:06

solvease



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!