5

I just installed the Media module v 7.x-2.0-alpha3 along with WYSIWYG, CKEditor, and Image Resize Filter. (The site has many other modules active.) The site also uses Display Suite, and its view modes are used for different types of images. My use case is for images embedded in the Filtered HTML text format, not as separate entities in a content type.

When an image is first embedded, its source code is like this:

[[{"fid":"161","view_mode":"default","fields":{"format":"default","field_file_image_alt_text[und][0][value]":"f asdfasdf"},"type":"media","attributes":{"alt":"alt text","class":"media-element file-default"}}]]

From my reading, I found that checking "Convert Media tags to markup" at mysite/admin/config/content/formats/filtered_html is required. I have verified that is active.

Instructions at https://www.drupal.org/node/1599070 include "Image resize filter" is AFTER "Convert Media tags to markup" and my filters are in that order.

If I double-click an embedded image in the CKEditor and make it a captioned image, then the Media tags are converted to markup. If a caption isn't added, the Media tags do not get converted.

Based on my configuration, can anyone suggest why the conversion is not occurring?

enter image description here enter image description here

  • I have the same problem. Do you have any solution for that problem now? – schulle877 Sep 8 '14 at 5:51
  • I too have the same issue and its driving me mad. – PUncle Sep 29 '14 at 13:37
  • schulle877, I have not found a solution for this yet. – Paul S. Jul 16 '15 at 0:40
  • The image resize filter should be after media tags for markup. Check that the filter is allowing images tags also. – cayerdis Nov 25 '15 at 15:16
  • Just in case that you have done anything and it still does not working: make sure that all double quotes (") are properly opened and closed in the node's body field, otherwise you wiil get unrendered items ([[{"type":"media","view_mode":"media_original","fid":"995"}}]]). Perhaps this a media's module bug! – mchar Oct 4 '16 at 14:00
4

I was having this same problem and have solved it. My problem was not rendering the text in the correct format in the template. So if you are using a custom theme, .tpl or whatever you need to make sure you render it correctly. I had it like this:

<?php print $node->field_main_body['und'][0]['value'] ;?>

Changing this to proper rendering using field_view_field fixed it for me:

<?php print render(field_view_field('node', $node, 'field_main_body', array('label'=>'hidden'))) ;?>

Hope that's helpful

  • In my case, this was the cause. I was printing the value instead of the rendered markup. – Permana Sep 29 '15 at 7:24
  • I'd upvote a thousand times more if I could. Wow what a pain it was to figure this out. I even asked in another thread like half a year ago and got no response. You'd think with all the minds behind drupal you wouldn't need some special way to render to handle media tags... in this day and age. Thanks a ton – Kai Qing Mar 7 '17 at 23:15
0

Might be worth checking that your "Limit html tags" isnt limiting your img tags

  • This does not provide an answer to the question. To critique or request clarification from an author, leave a comment below their post - you can always comment on your own posts, and once you have sufficient reputation you will be able to comment on any post. – niksmac Jun 4 '15 at 4:03
  • I need to have 50 rep points to comment on a post? How do you suggest i leave comments/ request more info, without answering, if i cant comment ? – zach.bimson Jun 4 '15 at 12:43
  • The list of allowed HTML tags does allow img tags. – Paul S. Jul 16 '15 at 0:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.