Skip to content

Instantly share code, notes, and snippets.

@lhuria94
Last active February 17, 2017 06:04
Show Gist options
  • Save lhuria94/03303322914ce549094d693eefb12011 to your computer and use it in GitHub Desktop.
Save lhuria94/03303322914ce549094d693eefb12011 to your computer and use it in GitHub Desktop.
Remove image object markup from rendering in Drupal 7 (Helpful for teaser display)
<?php
$body_text_alter_params = array(
'max_length' => 300,
'ellipsis' => FALSE,
'word_boundary' => TRUE,
'html' => FALSE,
);
// Removes unnecessary markup.
$trimmed_body = check_plain(strip_tags($value->body_value, '<p>'));
// Trimming the body text as per the parameters defined in
// {$body_text_alter_params}.
$trimmed_body = views_trim_text($body_text_alter_params, drupal_html_to_text(check_markup($trimmed_body, $value->body_format)));
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment