Skip to content

Instantly share code, notes, and snippets.

@sinkovsky
Created November 18, 2009 08:35
Show Gist options
  • Save sinkovsky/237657 to your computer and use it in GitHub Desktop.
Save sinkovsky/237657 to your computer and use it in GitHub Desktop.
sub _hdlr_entry_body_has_image {
my($ctx, $args, $cond) = @_;
return 0 if (!$ctx->stash('entry'));
my $entry_text = &MT::Template::Context::_hdlr_entry_body;
my @paragraphs = split(/<p[^>]*>/i, $entry_text);
## just checking for img tag in the
## first three paragraphs, skip first array element,
## because of that element is fake element
## (because of specialities split function)
foreach (@paragraphs[1..3]) {
return 1 if (/<img[^>]*>/i);
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment