_filter_url_trim

Versions
5 – 7
_filter_url_trim($text, $length = NULL)

Shortens long URLs to http://www.example.com/long/url...

▾ 3 functions call _filter_url_trim()

_filter_url in modules/filter/filter.module
URL filter. Automatically converts text web addresses (URLs, e-mail addresses, ftp links, etc.) into hyperlinks.
_filter_url_parse_full_links in modules/filter/filter.module
Make links out of absolute URLs.
_filter_url_parse_partial_links in modules/filter/filter.module
Make links out of domain names starting with "www."

Code

modules/filter/filter.module, line 858

<?php
function _filter_url_trim($text, $length = NULL) {
  static $_length;
  if ($length !== NULL) {
    $_length = $length;
  }

  // Use +3 for '...' string length.
  if (strlen($text) > $_length + 3) {
    $text = substr($text, 0, $_length) .'...';
  }

  return $text;
}
?>
Login or register to post comments
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.