If you have a content manager that likes to use inline images in the Body field of a Drupal site, you might run into an issue where they want an image inserted at the beginning of the field but don't want it to display in a teaser. Of course, you could tell them to use the "Summary" part of the body field to manually set the teaser, but some content managers tend to forget about that, and you're also dealing with an issue of entering data twice. No one wants to enter anything twice if they don't have to (even if it is merely copy and paste).

You could create a custom display formatter, but maybe you're not comfortable with PHP. Or maybe you're just pressed for time.

The Advanced Text Formatter module is exactly what you need to solve this problem. After enabling it, you'll get an option on text fields (like the Body field) to use this formatter. After selecting it, you'll get the following configuration details:

Now you can better control what gets pulled out of the Body field to use on your teaser. To keep that inline image out, just choose the "Limit allowed HTML tags" filter and make sure the <img> tag is not in the list of allowed tags.

If you liked this post, you should share it...

StumbleUpon icon
LinkedIn icon
Google icon
Reddit icon

Comments

Yes, the Advanced Text Formatter module is very useful for certain cases preventing using a custom formatter.

Another module which seems to almost do more is the Simple Field Formatter https://drupal.org/project/simple_field_formatter which has many of the options from views, and is more popular. The name "Simple" does not mean that the module cannot do many things, it can, but is easy to use for those familiar with views.

It would be nice to see more formatting options like the ones these modules provide moved into core which are similar to the options in views as they are such common use cases to modify data on output. Perhaps we'll be seeing those soon.

Either module can be useful depending on the formatting required of course.

Cheers,
darrellulm
https://drupal.org/user/46284

I'm actually a huge fan of Smart Trim, which does a lot of this, as well, but includes the use of the summary field and Read More links.

Most of my clients are still using the default editor which is completely user unfriendly. I personally recommended some to use the advanced editors such as what you have provided here.

I still remember those days when there were no editors and I used to write codes for everything.

Ayesha

Add comment

Stay updated!