Shorten Number of Words in Item Metadata

Is there a way to limit the number of words that display in the Item metadata on the browse items page? I am aware that I can shorten or lengthen the number of characters by editing this code <?php if ($title = metadata('item', array('Dublin Core', 'Title'), array('snippet'=>250))): ?> for the various metadata fields. However, I would like to limit the number of whole words in the result and use an ellipsis to substitute for the remaining words. Is there a way to do this? Thank you.

Instead of snippet, use snippet_by_word_count($text).

Hello Patrick,

Please excuse the slow response. I thought I responded earlier but alas I did not. Thank you for the information I will test it.