Info
- 13 posts
- 6 voices
- Started 4 years ago by beaver6813
- Latest reply from ganzua
- This topic is not resolved
Limit long words
-
- Posted 4 years ago #
Hey Guys,
We're currently having some problems with longish words flowing out of the design, all normal words get text wrapped when they reach the end however long url's or lines don't, any ideas how to resolve?
http://www.bblocked.org/forums/topic/10?replies=2
An example can be seen there, that url would even go into the background if i hadn't shortened it, any ideas guys?
-
- Posted 4 years ago #
Yeah, the easy fix for this is adding:
.post {overflow: hidden; } -
- Posted 4 years ago #
Yes but that won't wrap the word down or shorten it, it'll just cut it off... any other solutions?
-
- Posted 4 years ago #
You could try this:
.post {overflow: scroll; }
Should scroll the extra content... I think that's what they are doing here, or something like that.
-
- Posted 4 years ago #
It sounds like you're looking for something like the proprietary word-wrap CSS property which works in IE browsers only, as far as I know.
.post {word-wrap: break-word; } -
- Posted 4 years ago #
You want
.post { overflow: auto; }which isn't actually the automatic setting - but it's the one that automatically adds a scrollbar if the post is too wide. Like multiline code here, it'll add the scrollbar only if needed. Also handy for images.
And lol at everyone suggesting something else. :P
-
- Posted 4 years ago #
oh right, auto... duh! (slaps forehead)
-
- Posted 4 years ago #
Are you interested in a plugin that will force spaces into long urls?
-
- Posted 4 years ago #
Ahhh that auto worked a treat ;-) I've used the break-word as well for IE so it doesn't even need to scroll when words are too long, in FF it just scrolls. Although a plugin to shorten long url's words etc might be quite cool, like:
http://www.ilovebbpress.com/bla/blab/blalblba/indexnop/123
to
http://www.ilovebbpress.com/bla.../123If I get time next week I might make one... but don't quote me on that :-P
Thanks guys for the help!
-
- Posted 4 years ago #
Here you are... ported from wp-chunk (literally only had to change the filter names)
<?php /* Plugin Name: bb-chunk Description: Shortens the display of urls so they won't break your site theme. Ported from wp-chunk 2.0 ( http://www.village-idiot.org/archives/2006/06/29/wp-chunk/ ) Author: The How-To Geek Author URI: http://www.howtogeek.com Version: 0.1 */ function make_chunky($ret) { // pad it with a space $ret = ' ' . $ret; $ret = preg_replace("#(^|[\n ])([\w]+?://[\w\#$%&~/.\-;:=,?@\[\]+]*)#is", "<a href='' rel='nofollow'></a>", $ret); $ret = preg_replace("#(^|[\n ])((www|ftp)\.[\w\#$%&~/.\-;:=,?@\[\]+]*)#is", "<a href='http://' rel='nofollow'></a>", $ret); //chunk those long urls chunk_url($ret); $ret = preg_replace("#(\s)([a-z0-9\-_.]+)@([^,< \n\r]+)#i", "<a href=\"mailto:@\">@</a>", $ret); // Remove our padding.. $ret = substr($ret, 1); return($ret); } function chunk_url(&$ret) { $links = explode('<a', $ret); $countlinks = count($links); for ($i = 0; $i < $countlinks; $i++) { $link = $links[$i]; $link = (preg_match('#(.*)(href=")#is', $link)) ? '<a' . $link : $link; $begin = strpos($link, '>') + 1; $end = strpos($link, '<', $begin); $length = $end - $begin; $urlname = substr($link, $begin, $length); /** * We chunk urls that are longer than 50 characters. Just change * '50' to a value that suits your taste. We are not chunking the link * text unless if begins with 'http://', 'ftp://', or 'www.' */ $chunked = (strlen($urlname) > 50 && preg_match('#^(http://|ftp://|www\.)#is', $urlname)) ? substr_replace($urlname, '.....', 30, -10) : $urlname; $ret = str_replace('>' . $urlname . '<', '>' . $chunked . '<', $ret); } } remove_filter('post_text', 'make_clickable'); add_filter('post_text', 'make_chunky'); ?> -
- Posted 4 years ago #
Actually, seems to have flaky behavior unless you remove this line:
remove_filter('post_text', 'make_clickable');
Seems to work pretty well otherwise.
-
- Posted 4 years ago #
Whenever I try to activate this plugin I get this error message;
Plugin could not be activated; it produced a Fatal Error.
-
You must log in to post.